题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/4ec4325634634193a7cd6798037697a8
#include <stdio.h> #include<string.h> int main() { char target[6],str[81],n,ans=0; while(gets(target)){ //gets(target); if(strcmp(target,"#")==0||strcmp(target,"\n")==0) return 0; gets(str); for(int i=0;target[i]!='\0';i++){ ans=0; for(int j=0;str[j]!='\0';j++){ if(str[j]==target[i]) ans++; } printf("%c %d\n",target[i],ans); }} }