#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=='B')cout<<2;hh;
| ^~~~
./Main.cpp:11:1: error: ‘else’ without a previous ‘if’
11 | else if(a=='C')cout<<3;hh;
| ^~~~
./Main.cpp:12:1: error: ‘else’ without a previous ‘if’
12 | else if(a=='D')cout<<4;hh;
| ^~~~
./Main.cpp:13:1: error: ‘else’ without a previous ‘if’
13 | else cout<<5;hh;
| ^~~~