- #include <iostream>
- #include<iomanip>
- //圆周长C1、圆面积Sa、圆球表面积Sb、圆球体积Va、圆柱体积Vb。保留两位小数,每个结果后换行。两个浮点数,r和h
- using namespace std;
- int main()
- {
- const float PI=3.14,X=(4.0/3.0);
- //cout<<PI<<" "<<X<<endl;
- float r,h;cin>>r>>h;
- float C1,Sa,Sb,Va,Vb;
- C1=2*PI*r;
- Sa=PI*r*r;
- Sb=4*Sa;
- Va=X*PI*r*r*r;
- Vb=Sa*h;
- cout<<setiosflags(ios::fixed)<<setprecision(2)<<C1<<endl;
- cout<<Sa<<endl;
- cout<<Sb<<endl;
- cout<<Va<<endl;
- cout<<Vb<<endl;
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/140320149048.html
来源: http://www.codesnippet.cn/detail/140320149048.html