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 |
一次AC,贴下代码,水水更健康#include <iostream> using namespace std; int main() { char a[4][72],c[28]; int b[28]={0},t,temp,i,j,max=0; for(i=0;i<4;i++) gets(a[i]); for(i=0;i<4;i++) //用数组b记住各个字符出现的词数 for(j=0;j<strlen(a[i]);j++) { if(a[i][j]<='Z'&&a[i][j]>='A') { temp=a[i][j]-'A'; b[temp]++; } } for(i=0;i<26;i++) //找出最大值 if(max<b[i]) max=b[i]; for(i=max;i>0;i--) { temp=0; for(j=0;j<26;j++) //清零 c[j]='\0'; for(j=0;j<26;j++) { if(b[j]==i) { for(t=temp;t<j;t++) c[t]=' '; c[j]='*'; c[j+1]='\0'; b[j]--; temp=j+1; } } j=0; while(c[j]) { if(j==0) cout<<c[j]; else cout<<' '<<c[j]; j++; } 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"<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator