标签 阶乘累加 下的文章

2. 计算圆的相关数据

题中给出的r、h在最后的答案中无意义

球的体积 V = 4/3 Pi r^3 球的表面积 S = 4 Pi r^2

体积公式推导和论证 : https://www.zhihu.com/question/405287938

#include <iostream>
#include <iomanip>

using namespace std;

const float PI = 3.1415926;

int main(){

    float r,h;

    cout << "请依次输入半径和圆柱体高度." << endl;
    cin >> r >> h;

//  cout << setpreise(2) << setfixed;
    cout << setiosflags( ios::fixed ) << setiosflags( ios::right ) << setprecission( 2 );
    cout << "\n周长:" << 2*PI*r;
    cout << "\n面积:" << PI*r*r;
    cout << "\n圆球表面积:" << 4 * PI * r * r;
    cout << "\n球的体积:" << 4.0 / 3.0 * PI * r * r *r;
    cout << "\n圆柱体体积:" << PI*r*r*h;
    cout << endl;
    return 0;
}

- 阅读剩余部分 -