//导入头文件
#include<stdio.h>
//主函数
int main(){
char c;//定义字符数组储每次获取的字符
int ENGLISH=0,english=0,space=0,number=0,other=0;//分别统计不同字符个数,初始值为均为0
printf("请输入要统计的字符: ");//信息提示
while((c=getchar())!='\n'){ //循环读取字符并判断类型,以末尾换行符’\n’结束
if(c>='a'&&c<='z'){ //判断是否为小写英文字母
english++;//数量+1
}else if(c==' '){ //判断是否为空格
space++;//数量+1
}else if(c>'0'&&c<='9'){ //判断是否为数字
number++;//数量+1
}else if(c>='A'&&c<='Z'){
ENGLISH++;
}
else{
other++;//数量+1
}
printf("upper: %d lower: %d blank: %d digit: %d other: %d",ENGLISH,english,space,number,other);//信息提示
return 0;
}
#include<stdio.h>
//主函数
int main(){
char c;//定义字符数组储每次获取的字符
int ENGLISH=0,english=0,space=0,number=0,other=0;//分别统计不同字符个数,初始值为均为0 printf("请输入要统计的字符: ");//信息提示
while((c=getchar())!='\n'){ //循环读取字符并判断类型,以末尾换行符’\n’结束
if(c>='a'&&c<='z'){
//判断是否为小写英文字母
english++;//数量+1
}
else if(c==' '){
//判断是否为空格
space++;//数量+1
}
else if(c>'0'&&c<='9'){
//判断是否为数字
number++;//数量+1
}
else if(c>='A'&&c<='Z'){
ENGLISH++;
}
else{
other++;//数量+1
}
}
printf("upper: %d lower: %d blank: %d digit: %d other: %d",ENGLISH,english,space,number,other);//信息提示
return 0;
}
#include<stdio.h>
int main(void)
{
/*********Begin*********/
int e=0,n=0,t=0,o=0;
char c;
while((c=getchar())!='\n'){
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
e++;//e统计字母个数
else if(c==' ')
t++;//t统计空格个数
else if(c>='0' && c<='9')
n++;//n统计数字个数
else
o++;//o统计其它字符个数
}
printf("%d %d %d %d",e,n,t,o);
/*********End**********/
return 0;
}