#11873: C++ 輸入字母 計算字母數量 並且依照字母數量多寡排序


z20818z (Unkown)


請問 我想要輸入A~Z字母

然後依照字母出現數量排序 

EX: 輸入 ABCCCC

然後顯示: C=4  A=1  B=1

然後D~Z=0 不顯示

我目前的構思是以下的式子

 

#include <iostream>
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int main(){
char s[100];
cin>>s;
int a,b,c,d[26]={0};
int e=strlen(s);
for(a=65;a<92;a++){
for(b=0;b<e;b++){
if(s[b]==char(a)){
d[a-65]++;
}
}
}
}