wtf输出格式有问题

P1598 垂直柱状图

```cpp #include<bits/stdc++.h> using namespace std; string s[4]; int a[27],maxn=-1; int main(){ getline(cin,s[0]); getline(cin,s[1]); getline(cin,s[2]); getline(cin,s[3]); for(int i=0;i<=3;i++){ for(int j=0;j<s[i].length();j++){ if(s[i][j]-64>=1&&s[i][j]-64<=26){ a[s[i][j]-64]++; } } } for(int i=1;i<=26;i++){ if(a[i]>maxn){ maxn=a[i]; } } for(int i=maxn;i>=1;i--){ for(int j=1;j<=26;j++){ if(a[j]>=i){ 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"; } ``` 稍微改了一下输出还是乱的
by jonnyyuan @ 2023-12-14 21:16:49


求大佬回复
by jonnyyuan @ 2023-12-14 21:17:45


```cpp #include<bits/stdc++.h> using namespace std; string s[4]; int a[27],maxn=-1; int main(){ getline(cin,s[0]); getline(cin,s[1]); getline(cin,s[2]); getline(cin,s[3]); for(int i=0;i<=3;i++){ for(int j=0;j<s[i].length();j++){ if(s[i][j]-64>=1&&s[i][j]-64<=26){ a[s[i][j]-64]++; } } } for(int i=1;i<=26;i++){ if(a[i]>maxn){ maxn=a[i]; } } for(int i=maxn;i>=1;i--){ for(int j=1;j<=26;j++){ if(a[j]>=i){ 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"; } ```
by Mitchellyi @ 2023-12-14 21:23:11


你的那里没加空格
by Mitchellyi @ 2023-12-14 21:23:42


|