题解 | #计算某字符出现次数#
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
/*
*This is a solution by using C language.
*Author ChrisJohnson
*Email:chrisjohnsoncode@outlook.com
*/
#include <stdio.h>
int main() {
char string[1500];
char ch;
gets(string);
ch = getchar();
int i = 0,count=0;
while (string[i] != '\0') {
if (toupper(string[i])==toupper(ch)) count++;
i++;
}
printf("%d\n", count);
return 0;
}
查看20道真题和解析