竹園論壇

標題: [TOJ]113.跳躍 求除錯 [打印本頁]

作者: Panda_Liu    時間: 2014-8-19 11:12
標題: [TOJ]113.跳躍 求除錯
本帖最後由 Panda_Liu 於 2014-8-19 20:10 編輯

[C++] 純文本查看 復制代碼
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>

using namespace std;
int main()
{
        int w;
        cin>>w;
        char s[w+1],rl;
        for(int i=0;i<w;i++)
        {
                cin>>s;
        }
        cin>>rl;
        if(rl=='L')
        {
                for(int i=0;i<w;i++)
                {
                        if(s=='P')
                        {
                                s='.';
                                s[i-1]='P';
                                break;
                        }
                }
        }
        if(rl=='R')
        {
                for(int i=0;i<w;i++)
                {
                        if(s=='P')
                        {
                                s='.';
                                s[i+1]='P';
                                break;
                        }
                }
        }
        for(int i=0;i<w;i++)
        {
                cout<<s;
        }
        system("pause");
    return 0;
}

範例測資和自己測試都沒問題 但丟上去就WA
懇求大家幫忙

作者: visitorIKC    時間: 2014-8-19 11:42
在TOJ中,最後不換行會是一個很大的錯誤.




歡迎光臨 竹園論壇 (http://forum.tfcis.org/) Powered by Discuz! X3.2