*您好! 我正在制作一个程序,用户输入一个句子和程序 打印出一个句子中有多少个字母(首都和非首都)。 我做了一个程序,但它打印出奇怪的结果。请尽快帮忙。 :)字符串,C++中的字符比较
include <iostream>
include <string>
using namespace std;
int main()
{
string Sent;
cout << "Enter a sentence !"<<endl;
cin>>Sent;
for(int a=0;a<Sent.length();a++){
if (96<int(Sent[a])<123 || 64<int(Sent[a])<91){
cout << "this is letter"<< endl;
}else{
cout << "this is not letter"<< endl;
}
}
}
'a Dave
你能否附上“怪异的结果”? – Trinimon