题解 | #计算某字符出现次数#,求指教有没有可以改进的地方
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1?tpId=37&tqId=21225&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
#include <stdio.h> int main() { char str[1000]; char cha1,cha2; int a=0, b; while (scanf("%c", &cha1) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to str[a]=cha1; a++; } cha2=str[a-2]; for(b=0;a>=4;a--) { cha1=str[a-4]; b=b+(tolower(cha1)==tolower(cha2)); } printf("%d",b); return 0; }