为什么CE
查看原帖
为什么CE
916579
GoodLuckCat楼主2023/8/21 16:15
#include<iostream>
#define hh cout<<endl
using namespace std;
int main()
{
char a;
cin>>a;
if(a=='A')cout<<1;hh;
else if(a=='B')cout<<2;hh;
else if(a=='C')cout<<3;hh;
else if(a=='D')cout<<4;hh;
else cout<<5;hh;
}

报错信息显示:

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:1: error: ‘else’ without a previous ‘if’
   10 | else if(a==&#39;B&#39;)cout&lt;&lt;2;hh;
      | ^~~~
./Main.cpp:11:1: error: ‘else’ without a previous ‘if’
   11 | else if(a==&#39;C&#39;)cout&lt;&lt;3;hh;
      | ^~~~
./Main.cpp:12:1: error: ‘else’ without a previous ‘if’
   12 | else if(a==&#39;D&#39;)cout&lt;&lt;4;hh;
      | ^~~~
./Main.cpp:13:1: error: ‘else’ without a previous ‘if’
   13 | else cout&lt;&lt;5;hh;
      | ^~~~
2023/8/21 16:15
加载中...