简单的编辑程序问题,速求答案!

2025-12-17 14:10:56
推荐回答(6个)
回答1:

不知道你要用什么语言,用C语言编一个.
#include
int isChar(char ch){/*是字母返回1,否则返回0*/
return (ch >= 'A' && ch <= 'Z' )
|| (ch >= 'a' && ch <= 'z');
}

int main(){
int charNum = 0;
int digitNum = 0;
int spaceNum = 0;
int otherNum = 0;
char ch;

do{
ch = getchar();
if( ch == '\n')break;
if(ch >= '0' && ch <= '9') digitNum++;
else if( isChar(ch) ) charNum++;
else if( ch == ' ') spaceNum++;
else otherNum++;
}while(1);

printf("char number : %d\ndigit number : %d\nspace number: %d\nother number:%d\n",
charNum,digitNum,spaceNum,otherNum);
}

在下也是初学者,共同进步吧.

回答2:

我觉得把这种问题没什么人愿意回答

回答3:

哈~貌似上大学的时候有道考试题是这个,不会是你在考试呢吧

回答4:

你在什么环境中输入的字符??office???

回答5:

你想要用什么编程语言编写呢?

回答6:

经常练的题