*您好! 我正在製作一個程序,用戶輸入一個句子和程序 打印出一個句子中有多少個字母(首都和非首都)。 我做了一個程序,但它打印出奇怪的結果。請儘快幫忙。 :)字符串,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