Muxinfelix 2021-07-13 00:03 采纳率: 50%
浏览 22
已采纳

改程序中哪句是多重定义?

还有其余的逻辑错误和语法错有有哪些.求解
#include

using namespace std;

void main()
{
int count = 0, count1 = 0, count2 = 0, count3 = 0;

 mark = -9;

 while (mark != -9)
 {
     cout << "insert marks of students in your class, enter -9 to stop entering"; 

     cin >> mark;

     count++;

     if (mark >= 0 && mark <= 60);
        count1 = count1 + 1;
     else if (mark >= 61 && mark <= 70);
        count2 = count2 + 1;
     else if (mark >= 71 && mark <= 100);
        count3 = count3 + 1;
  }
  cout <<"Report of MTS3013 course" << endl;
  cout <<"Mark" << count << endl << endl;
  cout << "0-60" << "\t\t\t\t" << count1 << endl;
  cout << "61-70" << "\t\t\t\t" << count2 << endl;
  cout << "71-100" << "\t\t\t\t" << count3 << endl<< endl << endl;
  cout << "End of program";

}

  • 写回答

3条回答 默认 最新

  • CSDN专家-link 2021-07-13 05:28
    关注

    建议如下更改,否则count的值是不对的,把-9也算进去了

    #include <iostream>
    using namespace std;
    void main()
    {
        int count = 0, count1 = 0, count2 = 0, count3 = 0;
        int mark=0;
     while (1)
     {
         cout << "insert marks of students in your class, enter -9 to stop entering\n"; 
         cin >> mark;
         if(mark == -9)
             break;
         count++;
         if (mark >= 0 && mark <= 60)
            count1 = count1 + 1;
         else if (mark >= 61 && mark <= 70)//;
            count2 = count2 + 1;
         else if (mark >= 71 && mark <= 100)//;
            count3 = count3 + 1;
      }
      cout <<"Report of MTS3013 course" << endl;
      cout <<"Mark " << count << endl << endl;
      cout << "0-60" << "\t\t\t\t" << count1 << endl;
      cout << "61-70" << "\t\t\t\t" << count2 << endl;
      cout << "71-100" << "\t\t\t\t" << count3 << endl<< endl << endl;
      cout << "End of program";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 已采纳回答 7月13日
  • 创建了问题 7月13日

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c