level 1
heiheishuozi
楼主
谢谢您的帮助!刚学c++,有个题目是输入一串字符,求其中的字母,数字,空格和其他字符的个数。可?为什么总是比我输入的少一个阿!看了好几遍了,还是不知道错出在哪里!麻烦您了!
#include "stdafx.h"#
include
using namespace std;int main(int argc, char* argv[]){char c;int num=0,letter=0,space=0,other=0;cin>>c;while((c=getchar())!='\n'){if(((c>='a')&&(c<='z'))||((c>='A')&&(c<='Z')))letter++;else{if(c>='0'&&c<='9')num++;else{if(c==' ')space++;elseother++;}}}cout<<"num="<
2007年02月10日 09点02分
1
#include "stdafx.h"#
include
using namespace std;int main(int argc, char* argv[]){char c;int num=0,letter=0,space=0,other=0;cin>>c;while((c=getchar())!='\n'){if(((c>='a')&&(c<='z'))||((c>='A')&&(c<='Z')))letter++;else{if(c>='0'&&c<='9')num++;else{if(c==' ')space++;elseother++;}}}cout<<"num="<