#include <stdio.h>
int maxIndex(int a[],int length) { int i=0,returnIndex=0; for(i;i<length;i++) { if(a>a[returnIndex]) returnIndex=i; } return returnIndex; }
int main() { int count[4]={0,0,0,0}; int sortC[]={0,1,2,3}; int temp; int i; while((temp = getchar()) != '\n') { if(temp >= 'A' && temp <'E') { count[temp - 'A']+=1; } } for(i = 0;i<4;i++) { temp = maxIndex(count,4-i); printf("%c:%d次\n",'A' + sortC[temp],count[temp]);
count[temp]^=count[3-i]; count[3-i]^=count[temp]; count[temp]^=count[3-i];
sortC[temp]^=sortC[3-i]; sortC[3-i]^=sortC[temp]; sortC[temp]^=sortC[3-i]; }
return 0; }
|