求大佬指点:
/*
策略:
1.输入
2.转存桶
3.找到最高行
4.从上向下输出
(1)开头空格
(2)自符部分
[1]'* '
[2]' '
5.输出最底行
样例:
*------>maxx行
<-遍历空格-> *
* *
* <-中间空格-> * * *
* * * *
* * * * * *
* * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * *
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------>结尾输出
*/
#include<bits/stdc++.h>
using namespace std;
char word[50];
int num[50];
int main()
{
for(int i=1;i<=4;i++)
{
gets(word);//输入
int len=strlen(word);
for(int j=1;j<=len;j++)//遍历word集合
{
if(word[j]>='A'&&word[j]<='Z') num[word[j]-'A']++;//存入桶类型每个字符有多少个
}
}
int maxx=-1;
for(int i=1;i<=26;i++)
{
if(num[i]>maxx) maxx=num[i];//找出出现次数最多的字母(上限行)
}
while(maxx--)
{
for(int i='Z';i>='A';i--)//判断开头空格区域
{
if(i!=' ') break;
}
for(int i='A';i<='Z';i++)//输出行中字符部分
{
if(maxx<=num[i-'A']) cout<<"* ";
else cout<<" ";
}
cout<<endl;
}
cout<<"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";//最低行
return 0;
}