#include<stdio.h>
#include<string.h>
#define SIZE 1000
int main()
{
char ch;
char a[SIZE], b[1];
int cnt = 0;
int i=0;
while((ch = getchar()) != '\n'){
a[i] = ch;
i++;
}
scanf("%c",&ch);
if(ch >= 'a' && ch <= 'z')
ch = ch - 32;
b[0] = ch;
i=0;
for(i = 0;i<strlen(a) ;i++){
if(a[i] >= 'a' && a[i] <= 'z' )
a[i] = a[i]-32;
if(b[0] == a[i] )
cnt++;
}
printf("%d",cnt);
return 0;
}
用指针是不是会更简单,这个运行时间虽然没超时但是也太长,请教大佬们怎么改进呀