📄 c01a.cpp
字号:
// c01a.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
double Cylinder( double r, double h );
double Sphere( double r );
double Rectangle( double l, double w, double h );
int main(int argc, char* argv[])
{
double radius, height;
cout << "请输入圆柱体的半径和高:\n";
cin >> radius >> height;
double volume = Cylinder( radius, height );
cout << "该圆柱体的体积为:" << volume << endl;
cout << "请输入球半径:\n";
cin >> radius;
double areaOfSphere = Sphere( radius );
cout << "该球面的面积为:" << areaOfSphere << endl;
double length, width;
cout << "请输入长方体的长、宽、高:\n";
cin >> length >> width >> height;
volume = Rectangle( length, width, height );
cout << "该长方体的体积为:" << volume << endl;
return 0;
}
double Cylinder( double r, double h )
{
return r * r * M_PI * h;
}
double Sphere( double r )
{
return 4 * r * r * M_PI;
}
double Rectangle( double l, double w, double h )
{
return l * w * h;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -