kai


私信TA

用户名:dotcpp0593017

访问量:565

签 名:

等  级
排  名 4916
经  验 1555
参赛次数 0
文章发表 18
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

/*

输入一行文字,找出其中大写字母、小写字母、空格、数字以及其他字符各有多少

*/
#include<stdio.h>
#include<string.h>
int main()
{
	char buf[1024];
	printf("请输入一个字符串:\n");
	gets(buf);
	int upper_count = 0,lower_count = 0,digit_count = 0,space_count = 0,other_count = 0;
	char *prt = buf;
	while(*prt != '\0'){
		if(*prt>='A'&&*prt<='Z'){
			upper_count++;
		}else if(*prt>='a'&&*prt<='z'){
			lower_count++;
		}else if(*prt>='0'&&*prt<='9'){
			digit_count++;
		}else if(*prt==' '){
			space_count++;
		}
		else{
			other_count++;
		}
		prt++;
	}
	printf("大写字母:%d,小写字母:%d,数字:%d,空格:%d,其他:%d",upper_count, lower_count, digit_count, space_count, other_count);
	
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区