AC代码
1 #include <stdio.h> 2 #include <string.h> 3 int main () 4 { 5 char input[1001]; 6 scanf("%s",&input); 7 int length = strlen(input); 8 int list[10] = {0}; 9 int i; 10 for(i = 0;i < length;i++) 11 { 12 switch(input[i]) 13 { 14 case '0':list['0' - '0']++; 15 break; 16 case '1':list['1' - '0']++; 17 break; 18 case '2':list['2' - '0']++; 19 break; 20 case '3':list['3' - '0']++; 21 break; 22 case '4':list['4' - '0']++; 23 break; 24 case '5':list['5' - '0']++; 25 break; 26 case '6':list['6' - '0']++; 27 break; 28 case '7':list['7' - '0']++; 29 break; 30 case '8':list['8' - '0']++; 31 break; 32 case '9':list['9' - '0']++; 33 break; 34 35 } 36 } 37 for(i = 0;i < 10;i++) 38 { 39 if(list[i] != 0) 40 { 41 printf("%d:%d ",i,list[i]); 42 } 43 } 44 }