Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
晒个代码,读到4次回车结束输入#include <stdio.h> #include <algorithm> using namespace std; int main() { char ch; int maxn,cnt=0,t,alpha[26]={0}; bool flag; while(true) { scanf("%c",&ch); if(ch=='\n') { cnt++; if(cnt==4) break; continue; } if(ch-'A'>=0 && ch-'A'<26) { t=int(ch-'A'); alpha[t]++; } } maxn=0; for(int i=0;i<26;i++) maxn=max(alpha[i],maxn); cnt=maxn; while(cnt) { for(int i=0;i<26;i++) { if(i!=0) printf(" "); if(alpha[i]>=cnt) printf("*"); else printf(" "); } printf("\n"); cnt--; } for(int i=0;i<26;i++) { if(i!=0) printf(" "); ch='A'+i; printf("%c",ch); } printf("\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator