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 |
汗,贡献了一个PE之后,又贡献了一个WA,终于发现了错误的原因。居然中间有空格,并且输出最后一列的时候也有空格,很低级的错误啊#include <iostream> using namespace std; int main() { string str; int count[26]; memset(count, 0 , 26*sizeof(int)); for(int i=0;i!=4;i++) { getline(cin , str); for(string::iterator iter = str.begin(); iter!=str.end(); iter++ ) if(isupper(*iter)) count[*iter-'A']++; } int max=0; for(int i=0;i!=26;i++) if(max < count[i]) max = count[i]; char string[26][max]; for(int i=0;i!=26;i++) { memset(string[i], ' ' , max ); if(count[i] <= max) memset(string[i]+(max-count[i]), '*', count[i]); } for( int i=0; i!= max; i++) { for(int j=0; j!=26; j++) cout << string[j][i] <<' '; cout << endl; } for(char i='A'; i<='Z'; i++) cout << i <<' ' ; cout << endl; system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator