题解 | #计算某字符出现次数#
计算某字符出现次数
http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
#include<stdio.h>
#include<string.h>
int main()
{
char str[1000];
int count = 0;
char ch;
scanf("%[^\n]\n",str);
scanf("%c", &ch);
for(int i=0; i<strlen(str);i++)
{
if(ch>='0' && ch<='9' && ch==str[i])
count++;
else if((ch==str[i] || ch==str[i]+32 || ch==str[i]-32) && !(ch>='0' && ch<='9'))
count++;
}
printf("%d", count);
}