# include<stdio.h>int main(){ int n,i; double sum,grade,count; printf("entern:\n"); scanf("%d",&n); sum = 0; count = 0; for(i=1;i<=n;i++){ printf("enter grade#%d:",i); scanf("%d",&grade); sum = sum+grade; if(grade<60) count++; } printf("average=%.2f\n",sum/n); printf("count=%d\n",count); return 0;}编译过了 没有语法问题 但是最后运行的的结果不正确 都是零
1 回答
已采纳
asd8532
TA贡献143条经验 获得超187个赞
# include<stdio.h> int main() { int n,i; double sum,grade,count; printf("entern:\n"); scanf("%d",&n); sum = 0; count = 0; for(i=1;i<=n;i++){ printf("enter grade#%d:",i); scanf("%lf",&grade);//%d改成%lf sum = sum+grade; printf("sum=%f\n",grade); if(grade<60) count++; } printf("average=%.2f\n",sum/n); printf("count=%lf\n",count);//这里也是改成%lf return 0; }
- 1 回答
- 0 关注
- 1385 浏览
添加回答
举报
0/150
提交
取消