PAT 1009 說反話

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    using namespace std;
    typedef long long ll;
    char a[82][82];
    int cnt;
    int main()
    {
        while(scanf("%s",a[cnt])!=EOF){
            cnt++;//***** 由於這裏把cnt放到上面的判斷中去了導致 最後在判斷EOF的時候多判斷了一下 導致輸出時多輸出了一個空格出錯
        }
           printf("%d\n",cnt);
        for(int i=cnt-1;i>=0;i--){
            printf("%s",a[i]);
            if(i>0)putchar(' ');
        }

        return 0;
    }

找錯找了很久,還是細節上出的問題。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章