输入一行字符,以回车做结束标志,统计出其中大写字母个数,小写字母个数,特殊字符,
输入一行字符,以回车做结束标志,统计出其中大写字母个数,小写字母个数,特殊字符,求大佬指点!!!
[此贴子已经被作者于2019-6-18 11:31编辑过]
#include <stdio.h> #include <stdlib.h> #include <ctype.h> int main(void) { char ch = {0}; int i, j, k, n; i = j = k = n = 0; printf("please you input the string:"); while((ch=getchar())&&ch != '\n'){ if(islower(ch)){ i++;//小写字母 }else if(isupper(ch)){ j++;//大写字母 }else if(isdigit(ch)){ k++;//十进制数字 }else{ n++;//这里是除大小写字母,十进制数字外都按特殊字符对待了 } } printf("The lowercase letter is%d, the capital letter is%d, the number is%d, and the special character is%d\n", i, j, k, n); system("pause"); return 0; }