25 lines
502 B
C++
25 lines
502 B
C++
|
#include <iostream>
|
||
|
#include <iomanip>
|
||
|
#include <cmath>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int main() {
|
||
|
double r;
|
||
|
const double PI = 3.14;
|
||
|
cout << "\u8f93\u5165\u534a\u5f84: ";
|
||
|
cin >> r;
|
||
|
|
||
|
if (r < 0 || r > 100) {
|
||
|
cout << "\u8f93\u5165\u9519\u8bef: \u534a\u5f84\u5fc5\u987b\u4e3a0\u5230100\u4e4b\u95f4" << endl;
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
double volume = (4.0 / 3) * PI * pow(r, 3);
|
||
|
|
||
|
cout << fixed << setprecision(2);
|
||
|
cout << "\u4f53\u79ef: " << volume << endl;
|
||
|
|
||
|
return 0;
|
||
|
}
|