题解 | #计算某字符出现次数#
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
没找到c语言正确代码,出一个:
#include <stdio.h>
#include <ctype.h>int main(){
char s[1010];
char c;
fgets(s, 1010, stdin);
c = getchar();
if(isupper(c)) c = tolower(c);
int count = 0;
for(int i = 0; s[i] != '\0';i++){
if(isalpha(s[i])) s[i] = tolower(s[i]);
if(c == s[i]) count++;
}
printf("%d",count);
return 0;
}
#C笔试面试##字节跳动深圳租房##游戏开发##京东招聘##咪咕互娱#