代码如下:
- #include <iostream>
- using namespace std;
- int main() {
- int letter = 0, blank = 0, digit = 0, other = 0;
- char ch;
- char s_letter[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
- char b_letter[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
- int num[26]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- for (int i = 1; i <= 10000; i++) {
- ch = cin.get();
- if(ch == '#')break;
- for(int j=0;j<=25;j++)
- {
- if(ch==s_letter[j] || ch==b_letter[j]) num[j]++;
- }
- }
- for(int i=0;i<=25;i++)
- {
- cout<<s_letter[i]<<"出现的个数为"<<num[i]<<endl;
- }
- }