题解 | #计算某字母出现次数#
计算某字母出现次数
http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
int main(){
int i = 0;
int count = 0;
int gap= 'A'-'a';
char seq;
char a;
seq = (char)malloc(500*sizeof(char));
while((seq[i] = getchar()) != '\n'){
i++;
}
scanf("%c",&a);
printf("\n%d\n",i);
while(i--){
if(a == seq[i] || a == seq[i]+gap || a == seq[i]-gap){
count++;
}
}
printf("%d",count);
return 0;
}