输入一批学生的成绩(整数),输出最高分。

墨蓝 2023-07-03 10:43 62阅读 0赞
  1. # include<stdio.h>
  2. int main()
  3. {
  4. int score,max=0;
  5. while(score>=0)
  6. {
  7. scanf("%d",&score);
  8. if(score>max)
  9. {
  10. max=score;
  11. }
  12. }
  13. printf("%d",max);
  14. return 0;
  15. }

采取while if嵌套结构,外层判断是否结束,内层判断最大值是否改变。

发表评论

表情:
评论列表 (有 0 条评论,62人围观)

还没有评论,来说两句吧...

相关阅读