【发布时间】:2013-03-21 23:52:15
【问题描述】:
*你好! 我正在制作用户输入句子和程序的程序 打印出一个句子中有多少个字母(大写和非大写)。 我做了一个程序,但它打印出奇怪的结果。请尽快提供帮助。 :)
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<b<c: C++ 不能那样工作。 -
能否请您附加“奇怪的结果”?
标签: c++ string char ascii string-comparison