poj 2136 Vertical Histogram

#include <iostream>
#include
<string>
using namespace std;
int letter[27];
int main()
{
string str;int i,j;
for( i=0;i<4;i++)
{
getline(cin,str);
for( j=0;j<str.size();j++)
if(str[j]>=65&&str[j]<=90)
letter[str[j]
-64]++;
}

int max=0;
for(i=1;i<=26;i++)
if(letter[i]>max)max=letter[i];

for( i=max;i>=1;i--)
{
for( j=1;j<=26;j++)
if(letter[j]>=i)
cout
<<"* ";
else
cout
<<" ";
cout
<<endl;
}
for( i=65;i<=90;i++)
cout
<<(char)i<<" ";
cout
<<endl;
return 0;
}

  

posted on 2011-07-18 11:39  sysu_mjc  阅读(144)  评论(0编辑  收藏  举报

导航