计算字符个数

计算字符个数

http://www.nowcoder.com/questionTerminal/a35ce98431874e3a820dbe4b2d0508b1

#include <stdio.h>
#include <string.h>
int main(void)
{
	char str[1000];
	char a, b;
	int count = 0;
	gets(str);
	scanf("%c", &a);
	if (('A' <= a) && (a <= 'Z'))
		b = a - 'A' + 'a';
	else if (('a' <= a) && (a <= 'z'))
		b = a - 'a' + 'A';
	else
		b = a;
	for (int i = 0; i < strlen(str); i++)
		if ((str[i] == a) || (str[i] == b))
			count++;
	printf("%d", count);
	return 0;
}

全部评论
复制你的代码可以通过,但是我照着你的代码mark一遍后就不能通过
点赞 回复
分享
发布于 2020-04-23 15:28

相关推荐

头像
03-18 09:09
Java
点赞 评论 收藏
转发
点赞 1 评论
分享
牛客网
牛客企业服务