为什么最后结果是0
题:https://img.imgdb.cn/item/604e0b315aedab222c184da8.jpg
https://img.imgdb.cn/item/604e0b545aedab222c185eec.jpg
https://img.imgdb.cn/item/604e0b685aedab222c186843.jpg
我的代码:#include <stdio.h>
main(){
int n,m;
int sum1=0;
int sum2=0;
int percent1;
int percent2;
float c1,c2;
scanf("%d",&n);
int score;
int i;
for(int m=1;m<=n;m++){
scanf("%d",&i);
score=i;
}
for(int j=1;j<=n;j++){
if(score>=60){
sum1++;
}
}
for(int a=1;a<=m;a++){
if(score>=85){
sum2++;
}
}
c1=sum1/n;
c2=sum2/n;
percent1=(int)c1*100;
percent2=(int)c2*100;
printf("%d%%\n",percent1);
printf("%d%%\n",percent2);
} https://cdn.jsdelivr.net/gh/hishis/forum-master/public/images/patch.gif #include <stdio.h>
main(){
int n,m;
int sum1=0;
int sum2=0;
int percent1;
int percent2;
float c1,c2;
scanf("%d",&n);
int score;
int i;
for(int m=0;m<n;m++){
scanf("%d",&i);
score=i;
}
for(int j=0;j<n;j++){
if(score>=60){
sum1++;
}
}
for(int a=0;a<n;a++){
if(score>=85){
sum2++;
}
}
c1=1.0*sum1/n;
c2=1.0*sum2/n;
percent1=(int)(c1*100+0.5);
percent2=(int)(c2*100+0.5);
printf("%d%%\n",percent1);
printf("%d%%\n",percent2);
}
页:
[1]