| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 715 人关注过本帖
标题:为什么这个程序在输入字符时就死循环?
取消只看楼主 加入收藏
huhao3225
Rank: 2
来 自:四川成都
等 级:论坛游民
帖 子:39
专家分:25
注 册:2011-11-9
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:0 
为什么这个程序在输入字符时就死循环?
#include<stdio.h>         //输入字符时,程序死循环
 main()
 {
     int score,a,x,total=0,errtotal=0;
     int acount=0,bcount=0,ccount=0,dcount=0,ecount=0;
     printf("Please enter scores:\n");
     while (scanf("%d",&score)!=EOF)
     {
      a=score/10;
      if (score>=0&&score<=100)
      {
            switch(a)
           {
             case 10:
              case 9:
                 {
                     ++acount;
                     ++total;
                     break;
                 }
             case 8:
                 {
                     ++bcount;
                     ++total;
                     break;
                 }
              case 7:
                 {
                     ++ccount;
                     ++total;
                     break;
                 }
             case 6:
                 {
                     ++dcount;
                     ++total;
                     break;
                 }
             default:
                 {
                     ++ecount;
                     ++total;
                     break;
                 }
           }
           
     }
         else
             {
                 printf("Sorry.You have input a wrong score.\n");
                 ++errtotal;
             }
    }
     printf("\n有效输入次数为:%d,无效输入次数为:%d\n",total,errtotal);
     printf("总人数为:%d,成绩分布如下:\n",total);
     printf("A级\tB级\tC级\tD级\tE级\n");
     printf("%d人\t%d人\t%d人\t%d人\t%d人\n",acount,bcount,ccount,dcount,ecount);
 }
搜索更多相关主题的帖子: scores include 
2011-11-13 23:03
快速回复:为什么这个程序在输入字符时就死循环?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018389 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved