#include
#include //改
#include
#define N 100
using namespace std;
int culculate(string *str)
{
int n=str->length();//改 int n=strlen(str);
//int a[26];
static int b[26];//改 C++不支持在函数外返回局部变量的地址,除非定义局部变量为 static 变量。
memset(b,0,sizeof(b));
for(int i=0;i
{
if((*str)[i]>='a' && (*str)[i]<='z' && (*str)[i]>='A' && (*str)[i]<='Z')//改(*str)[i]
{
if(isupper((*str)[i]))
{
(*str)[i]=tolower((*str)[i]);
}
b[(int)((*str)[i]-'a')]++;
}
return b;
}
return b;//增加一个 你自己再看看
}
int main()
{
string str;
cin>>str;
//int a[26]={0};
/ 一个指向整数的指针 */
int *a;
//a=culculate(str);//改
a=culculate(&str);//改
int s=0;
int max=a[0];
for(int i=0;i<26;i++)
{
if(max<a[i])
{
max=a[i];
}
s+=a[i];
}
cout<<"字母个数为"<<s<<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"<<endl;
cout<<"---------------------------------------------------"<<endl;
for(int k=0;k<max;k++)//i重复 改成k
{
for(int j=0;j<26;j++)
{
if(a[j])
{
cout<<"*"<<" ";
a[j]--;
}
}
cout<<endl;
}
return 0;
}