update
This commit is contained in:
parent
778ee62a92
commit
46f428497b
24
homework_2.cpp
Normal file
24
homework_2.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user