#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
char a;
int b[26]={0};
printf("输入一个字符串\n");
scanf("%c”,&a);
while (a != '\n') {
if (a >= 'A’&&a <= 'Z') {
a+=32;
b[a-'a']++;
}else if(a >= 'a’&&a <= 'z'){
b[a-'a']++;
}
scanf("%c”,&a);
}
for (int i = 0; i < 26; i++) {
if (b[i]) {
printf("%c:%d\n",i+'a’,b[i]);
}
}
}
return 0;
}
|
|