求助

B2014 与圆相关的计算

`r`是实数
by HarunluoON @ 2022-01-25 10:19:43


`int r;`
by a1029 @ 2022-01-25 10:19:55


改成`double r`
by HarunluoON @ 2022-01-25 10:21:56


@[魔方少年](/user/564380) 恐怕您都没有编译运行过
by a1029 @ 2022-01-25 10:22:13


`保留4位小数,每个数用一个空格隔开`
by a1029 @ 2022-01-25 10:23:14


谢谢哈@a1029和HarunluoON
by Jerryzm @ 2022-01-25 10:26:09


大家看看我的代码吧,出了神马问题?``` #include <bits/stdc++.h> using namespace std; int main() { double r,c,s; const double PI=3.14159; cin>>r; s=PI*r*r; c=(2*PI)*r; cout<<fixed<<setprecision(4)<<2*r<<endl cout<<fixed<<setprecision(4)<<c<<endl; cout<<fixed<<setprecision(4)<<s<<endl; return 0; } ```
by 20110728qianqingwen @ 2022-02-22 18:27:00


@[魔方少年](/user/564380) 1.r的定义改成double形式:double r; 2.输出时注意要保留四位小数:cout<<fixed<<setprecision(4)<<这里填要输出的数。
by nono126 @ 2022-05-15 12:20:10


首先r可能是小数,所以int就不要用了,然后浮点尽量用double,如果题目没有说必须用单精度就用双精度。 连续cout是换行输出,题目说用空格隔开啊, cout<<a<<" "<<b; 这样就可以 还有楼上的那位我补充一下, cout<<fixed<<setprecision(x)<<要输入的数; x的值最大为6 ——蒟蒻的发言
by cmytb @ 2022-09-03 19:53:38


如果用cout<<fixed<<setprecision(x)<<; **** 头文件用#include<ioman
by cmytb @ 2022-09-03 19:57:06


| 下一页