#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
int times[36];
char ch;
int num;
for(int i = 0; i < 36; i++)
{
times[i] = 0;
}
cout<<"請輸入字符"<<endl;
cin>>ch;
while(ch != '#')//'#'用於標誌字符串的結束
{
if(ch >= '0' && ch <= '9')
{
num = ch - '0';//times[0]~times[9]用於記錄'0'~‘9’的頻度
times[num]++;
}
else if(ch >= 'A' && ch <= 'Z')
{
num = ch - 'A' + 10;//times[10]~times[35]用於記錄A到Z的頻度
times[num]++;
}
else
{
cout<<"輸入字符錯誤!"<<endl;
}
cin>>ch;
}
for(int j = 0; j < 36; j++)//輸出輸入字符串的頻度值
{
cout<<times[j];
}
system("pause");
}