大佬速来!蒟蒻求助,getline(cin,a)有什么问题吗???
查看原帖
大佬速来!蒟蒻求助,getline(cin,a)有什么问题吗???
664620
Alpex楼主2022/8/4 10:01
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int main(){
    char a[101],b[101],c[101],d[101];
    int word[27]={0},maxn=-999;
    getline(cin,a);
    getline(cin,b);
    getline(cin,c);
    getline(cin,d);
    strcat(a,strcat(b,strcat(c,d)));
    
    for(int i=0;i<strlen(a);i++)
        if(a[i]!=' ')
            word[a[i]-96]++;
            
    for(int i=1;i<27;i++)
        if(word[i]>maxn)
            maxn=word[i];
            
    for(int i=maxn;i>0;i--){
        for(int j=1;j<27;j++){
            if(word[i]==maxn&&i!=26)
                cout<<"* ";
            else if(word[i]<maxn&&i!=26)
                cout<<"  ";
            else if(word[i]==maxn&&i==26)
                cout<<"*";
            else if(word[i]<maxn&&i==26)
                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;
}
2022/8/4 10:01
加载中...