我全都防出去了啊,没想到这道题不讲武德,搞,偷袭!

P1307 [NOIP2011 普及组] 数字反转

keepoing @ 2021-12-31 17:29:34

#include<stdio.h>
#include<string.h>
int main() {
    char s[50];
    int i=1,l;
    gets(s);
    l = strlen(s);
    char x[l];

    for (i = 0; i < l; i++) {
        x[l-1-i]=s[i];
    }

    i=0;
    if(s[0]=='-') {
        printf("-");
    }
    if(x[0]=='0') {
        i++;
    }
        if(s[0]=='-'&&x[1]=='0') {
        i++;
    }

    for (i; i < l; i++) {
        if(x[i]=='-') {
         continue;
        }
        if(x[i]=='0') {
         continue;
        }
        printf("%c",x[i]);
    }
}

做完才看到条件,哎


by Xeqwq @ 2021-12-31 17:40:56

不看题目你怪谁?


|