2014年6月14日 星期六

d012

#include
#include

int main(void) {
    char s[999];
    char s2[999];
    int stelen;
    int i;
    int count;
    while( gets(s)!=0 ) {
        count = 0;
        memset(s2, 0, 999);
        stelen = strlen(s);
        for (i=stelen-1; i>=0; i--) {
            s2[count] = s[i];
            count++;
        }
        if(!strcmp(s,s2)){
            printf("Yes\n");
        }else printf("No\n");
    }
    return 0;

}

tips:
1.單純結合d001與d011
2.ISO C90 forbids mixed declarations and code 變數不要宣告在太後面的地方,最好在邏輯之前。
3.一樣記得同樣的char array你在去宣告一次並不會變成新的array,要重複使用就要用memset去empty array。

沒有留言: