1. 程式人生 > >求球的體積

求球的體積

輸入半徑,輸出體積。
#include
double PI = 3.1415927;
using namespace std;
int main()
{
int number;
cout << "numeber of balls = ";
cin >> number;
float *a = new float [number];
cout << “input radius” << endl;
for (int i = 0; i < number; i++)
{
cin >> a[i];
}
cout << “corresponding volume :” << endl;
for (int i = 0; i < number; i++)
{
float V = (PI * 4.0 * a[i] * a[i] * a[i]) / 3.0;
cout << V << endl;
}
}