1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include <iostream> #include <string> #include <iomanip> #include <cmath> using namespace std; int main() { int n; double a,b,r; string str; cin >> n; for(int i = 0; i < n; i++) { cin >> str; if(str == "rectangle") { cin >> a; cin >> b; cout << fixed << setprecision(6) << a*b << endl; } else { cin >> r; cout << fixed << setprecision(6) << M_PI*r*r << endl; } } return 0; }