注册 登录
编程论坛 C++教室

请问错在哪里 ,一直编译运行有错

暮笙 发布于 2016-06-08 17:28, 3573 次点击
#include <iostream>
using namespace std;
int main ()
{ int score;
  int scorephrase;
  cout<<"请输入分数\n";
  cin>>score;
  if(score<0||score>100)
  {
        cout<<"此分数不存在"<<endl;
      system("pause");
      return 0;
   }
    scorephrase=score/10;
      switch (scorephrase);
             {  case 10:
                case 9:
                      cout<<score<<"  优"<<endl;
                    break;
                case 8:
                    cout<<score<<"  良"<<endl;
                    break;
                case 7:
                    cout<<score<<"  中"<<endl;
                    break;
                case 6:
                    cout<<score<<" 及格"<<endl;
                    break;
                default:
                    cout<<score<<"  不及格"<<endl;
                    break;
             }
system ("pause");
return 0;
}
2 回复
#2
wmf20142016-06-08 17:38
switch (scorephrase);去掉后面的分号试试。
#3
xu5414562016-06-10 23:44
1. 出错了,别只贴代码,把错误也贴出来,因为错误会提示哪一行,像你这种细节错误,需要一行一行看才行。
2. 代码注意排版,至少你发生一定要排版,否者看着很费劲
3. 除了错,很多的原因是因为你排版太差导致的,都是细节问题。
1