全部RE(玄关)

P1598 垂直柱状图

你看看我的代码 ```cpp #include <bits/stdc++.h> using namespace std; int a[26]; int main() { string s; for(int k=0; k<4; k++) { getline(cin,s); for(int i=0; i<s.size(); i++) { if(s[i]>='A'&&s[i]<='Z') { int t=s[i]-'A'; a[t]++; } } } int zd=a[0]; for(int i=1; i<26; i++) { if(a[i]>zd) { zd=a[i]; } } int x=0; for(int i=zd; i>0; i--) { for(int j=0; j<26; j++) { if(a[j]>=i) { if(j!=x) { cout<<" "; } cout<<"*"; } else { if(j!=x) { cout<<" "; } cout<<" "; } } cout<<endl; } for(int i=0; i<26; i++) { if(i!=0) { cout<<" "; } cout<<char('A'+i); } return 0; } ``````
by jame0329 @ 2024-04-05 17:38:35


|