计算字符个数
计算字符个数
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; }