2014年6月14日 星期六

d001

#include
#include
int main(void) {
    char s[999];
    int stelen = 0;
    int i = 0;
    while( gets(s)!=0 ) {
        stelen = strlen(s);
        for (i=stelen-1; i>=0; i--) {
            if(i!=0)printf("%c", s[i]);
            else printf("%c\n", s[i]);
        }
    }
    return 0;

}

tips:
1.for loop裡面不能宣告變數(ex: int i),似乎與c99有關
2.不能用scanf,測資裡有space,scant讀到space就讀完了。所以用gets。
3.scanf()讀取結尾是回傳EOF;gets()則是回傳0。

沒有留言: