标签:std man names nbsp font str ++ c语言 iostream
题目:
输入底面半径 r 和高 h ,输出圆柱体的表面积,保留3位小数。
样例输入:
3.5 9
样例输出:
Area = 274.889
思路:
圆柱体表面积为S, 底面面积为S1,侧面面积为S2,则S = 2S1 + S2。
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
const double PI = acos(-1.0);
double r = 0.0, h = 0.0;
double s = 0.0, s1 = 0.0, s2 = 0.0;
cin >> r >> h;
s1 = PI * r * r;
s2 = PI * r * 2 * h;
s = 2 * s1 + s2;
cout << "Area = ";
cout << setprecision(3) << fixed << s;
return 0;
}
标签:std man names nbsp font str ++ c语言 iostream
原文地址:https://www.cnblogs.com/Hello-Nolan/p/12108623.html