一段dev c++的问题,本人新手
#include<iostream>usingnamespacestd;intmain(){charA;charM;charN;charD;charP;charL;cha...
#include<iostream>
using namespace std;
int main()
{ char A;
char M;
char N;
char D;
char P;
char L;
char H;
char G;
char C;
cout<<"输入"<<endl;
cin>>A;
if(A==M)
cout<<"good"<<endl;
else if(A==N)
cout<<"great"<<endl;
else if(A==D)
cout<<"excellent"<<endl;
else if(A==P)
cout<<"ok"<<endl;
else if(A==L)
cout<<"just so so"<<endl;
else if(A==H)
cout<<"low"<<endl;
else if(A==G)
cout<<"XXX"<<endl;
else if(A==C)
cout<<"00000"<<endl;
else cout<<"none"<<endl
system("pause");
return 0;
}
无论我输入什么都显示none,这是为什么,求大神解答 展开
using namespace std;
int main()
{ char A;
char M;
char N;
char D;
char P;
char L;
char H;
char G;
char C;
cout<<"输入"<<endl;
cin>>A;
if(A==M)
cout<<"good"<<endl;
else if(A==N)
cout<<"great"<<endl;
else if(A==D)
cout<<"excellent"<<endl;
else if(A==P)
cout<<"ok"<<endl;
else if(A==L)
cout<<"just so so"<<endl;
else if(A==H)
cout<<"low"<<endl;
else if(A==G)
cout<<"XXX"<<endl;
else if(A==C)
cout<<"00000"<<endl;
else cout<<"none"<<endl
system("pause");
return 0;
}
无论我输入什么都显示none,这是为什么,求大神解答 展开
1个回答
展开全部
#include<iostream>
using namespace std;
int main()
{ char A;
/*
char M;
char N;
char D;
char P;
char L;
char H;
char G;
char C;
*/
cout<<"输入"<<endl;
cin>>A;
if(A=='M')
cout<<"good"<<endl;
else if(A=='N')
cout<<"great"<<endl;
else if(A=='D')
cout<<"excellent"<<endl;
else if(A=='P')
cout<<"ok"<<endl;
else if(A=='L')
cout<<"just so so"<<endl;
else if(A=='H')
cout<<"low"<<endl;
else if(A=='G')
cout<<"XXX"<<endl;
else if(A=='C')
cout<<"00000"<<endl;
else cout<<"none"<<endl;
system("pause");
return 0;
}
追问
多谢大神,我已经解决问题了,能问一句为什么要将a底下几行改为注释呢?还有双引号和单引号有什么不同呢?
追答
改成注释是没有用到,双引号是字符串,单引号是字符.至于字符串和字符的区别,那就百度一下.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询