1
已解决
芮奥运
高级光能
高级光能
哪错了?:
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,s1,s2,s3,s4,a[i];
cin>>n;
for(int i=1; i<=n; i++)
{
cin>>a[i];
if(a[i]>=90) s1++;
else if(a[i]>=75) s2++;
else if(a[i]>=60) s3++;
else s4++;
}
printf("%.2lf",100*s1/double(n));
cout<<"%"<<endl;
printf("%.2lf",100*s2/double(n));
cout<<"%"<<endl;
printf("%.2lf",100*s3/double(n));
cout<<"%"<<endl;
printf("%.2lf",100*s4/double(n));
cout<<"%"<<endl;
return 0;
}
0
已采纳
方宇哲
资深守护
资深守护
要用浮点型
输出:
f=b/n*100; g=c/n*100; h=d/n*100; j=e/n*100; printf("%.2f%\n",f); printf("%.2f%\n",g); printf("%.2f%\n",h); printf("%.2f%\n",j);
方宇哲在2018-01-27 15:59:44追加了内容
主要判断(小部分没有!!!):
if(a[i]>=90&&a[i]<=100) { b++; }else if(a[i]<90&&a[i]>=75) { c++; }else if(a[i]<75&&a[i]>=60) { d++; }
0
0
0
0
方宇哲
资深守护
资深守护
!!!!!!!!!!!!!!!!!!!!!!!!!!
浮点型
!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!
只有a[100]是整型
!!!!!!!!!!!!!!!!!!!!!!!!!!
0