#34865: UVa 寫法過不了原因


00852038@email.ntou.edu.tw (曹文耀)

學校 : 不指定學校
編號 : 229143
來源 : [101.10.45.174]
最後登入時間 :
2023-07-23 14:16:12
c045. 00490 - Rotating Sentences -- UVa490 | From: [1.169.75.238] | 發表日期 : 2023-04-22 16:41

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string str[100];
    int num =0,max = 0;
    
    while(getline(cin,str[num])){
        
        if(str[num].length() > max)
            max = str[num].length();
        num++;
        
    }
    
    for(int i = 0; i < max;i++){
        
        for(int j = num-1 ; j > -1;j--){
            if(str[j].length() <= i){
                cout<<" ";
            }else{
                cout<<str[j][i];
            }
        }
        cout<<endl;
    }
    
    return 0;
}
 

 
#34866: Re: UVa 寫法過不了原因


00852038@email.ntou.edu.tw (曹文耀)

學校 : 不指定學校
編號 : 229143
來源 : [101.10.45.174]
最後登入時間 :
2023-07-23 14:16:12
c045. 00490 - Rotating Sentences -- UVa490 | From: [1.169.75.238] | 發表日期 : 2023-04-22 16:42

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string a,str[100];
    int num =0,max = 0;
    
    while(getline(cin,a)){
        
        str[num]=a;
        if(str[num].length() > max)
            max = str[num].length();
        num++;
        
    }
    
    for(int i = 0; i < max;i++){
        
        for(int j = num-1 ; j > -1;j--){
            if(str[j].length() <= i){
                cout<<" ";
            }else{
                cout<<str[j][i];
            }
        }
        cout<<endl;
    }
    
    return 0;
}
但改成這樣就能過了,真的不是很懂為啥ㄟ,話說上面過不了的原因是runtime error

 
#34874: Re: UVa 寫法過不了原因


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
c045. 00490 - Rotating Sentences -- UVa490 | From: [27.52.41.9] | 發表日期 : 2023-04-22 22:38

#include
#include
using namespace std;

int main()
{
    string a,str[100];
    int num =0,max = 0;
    
    while(getline(cin,a)){
        
        str[num]=a;
        if(str[num].length() > max)
            max = str[num].length();
        num++;
        
    }
    
    for(int i = 0; i < max;i++){
        
        for(int j = num-1 ; j > -1;j--){
            if(str[j].length() <= i){
                cout<<" ";
            }else{
                cout<            }
        }
        cout<    }
    
    return 0;
}
但改成這樣就能過了,真的不是很懂為啥ㄟ,話說上面過不了的原因是runtime error


兩種我送出都能AC,或許是系統當時有問題?

 
ZeroJudge Forum