Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

汗,贡献了一个PE之后,又贡献了一个WA,终于发现了错误的原因。居然中间有空格,并且输出最后一列的时候也有空格,很低级的错误啊

Posted by bupt_chen at 2008-07-04 17:33:05 on Problem 2136 and last updated at 2008-07-04 17:33:30
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator