#880: 不知道為何會少一個空白= =


bird (GG)

學校 : 长郡中学
編號 : 2681
來源 : [111.255.206.95]
最後登入時間 :
2010-10-23 20:18:46
c045. 00490 - Rotating Sentences -- UVa490 | From: [140.117.182.115] | 發表日期 : 2008-11-05 22:47

#include<iostream>
#define max 100
using namespace std;
struct stack
{
    char a[max+1];
};
typedef struct stack stk;
int main()
{
    stk obj[max];
    int j=0,s=0,maxi=0;

    while(cin.getline(obj[s].a,max)){
    if(strlen(obj[s].a)>maxi)
    maxi=strlen(obj[s].a);
    s++;}
    for(int j=0;j<maxi;j++){
        for(int i=s-1;i>=0;i--){
            if(obj[i].a[j]=='\0')
            continue;
            cout<<obj[i].a[j];
        }
        cout<<endl;
    }
    system("pause");
    return 0;
}
 
#881: Re:不知道為何會少一個空白= =


snail (蝸牛)

學校 : 新北市立板橋高級中學
編號 : 2021
來源 : [203.64.161.123]
最後登入時間 :
2024-10-16 10:38:18
c045. 00490 - Rotating Sentences -- UVa490 | From: [218.211.230.114] | 發表日期 : 2008-11-06 05:17

長度不足的字串要補印空白,而不是跳過不印。 
ZeroJudge Forum