#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define k 1000 int main() { int i = 0; char num[k]; for (i = 0; i < k; i++) { num[i] = 'a'; } int zhen[k]; for (i = 0; i < k; i++) { zhen[i] = -1; } scanf("%s", num); i = 0; while (num[i] != '\0') { zhen[i] = num[i] - '0'; i++; } int count[10] = {0}; for (i = 0; i < k; i++) { if (zhen[i] == -1) { break; } if (zhen[i] == 0) { count[0]++;continue; } if (zhen[i] == 1) { count[1]++;continue; } if (zhen[i] == 2) { count[2]++;continue; } if (zhen[i] == 3) { count[3]++;continue; } if (zhen[i] == 4) { count[4]++;continue; } if (zhen[i] == 5) { count[5]++;continue; } if (zhen[i] == 6) { count[6]++;continue; } if (zhen[i] == 7) { count[7]++;continue; } if (zhen[i] == 8) { count[8]++;continue; } if (zhen[i] == 9) { count[9]++;continue; } } for(i=0;i<10;i++){ if(count[i]!=0){ printf("%d:%d\n",i,count[i]); } } }
标签:count,num,pat,++,乙级,zhen,int,continue,1021 From: https://www.cnblogs.com/Npc-Hb/p/17176292.html