sixer_120201 @ 2023-10-19 20:14:12
十几个评测点,一眼望去全部都是WA
求大佬帮忙看看代码错在哪里
代码如下:
# include<iostream>
# include<iomanip>
using namespace std;
int main(){
int num;cin>>num;
int a;
int sum=0;
for (int i=1;i<=num;i++){
cin>>a;
sum=sum+a;
}
cout<<fixed<<setprecision(2)<<sum/num<<endl;
}
他给的是:too short on line one
求帮助!
by zqh123b @ 2023-10-19 20:16:14
@sixer_120201
样例过了吗
by xudongyi1 @ 2023-10-19 20:18:15
@sixer_120201
输出改成 out<<fixed<<setprecision(2)<<sum*1.0/num<<endl;
因为 sum
是整数类型的。
by xudongyi1 @ 2023-10-19 20:18:54
cout<<fixed<<setprecision(2)<<sum*1.0/num<<endl;
刚刚错了
by sixer_120201 @ 2023-10-31 19:44:45
@xudongyi1
感谢
by lyl20110209 @ 2023-12-24 11:19:22
飞舞