100pts,Unaccepted.求调

P1307 [NOIP2011 普及组] 数字反转

cao_20115 @ 2024-05-10 21:56:32

1 Wrong Answer.wrong answer Too short on line 1.

Code

#include <bits/stdc++.h>
using namespace std;
char str[10086];
int len;
bool flag;
int main(){
scanf("%s", str);
len = strlen(str);
if (str[0] == '-') {
printf("-");
reverse(str + 1, str + len);
for (int i = 1; i < len; ++i) {
if (flag || str[i] != '0') {
printf("%c", str[i]);
flag = true;
}
}
} else {
reverse(str, str + len);
for (int i = 0; i < len; ++i) {
if (flag || str[i] != '0') {
printf("%c", str[i]);
flag = true;
}
}
}
return 0;
}

by guer_loser_lcz @ 2024-05-10 22:00:12

@cao_20115 特判是零的情况。


by cao_20115 @ 2024-05-10 22:04:06

@lczcy1 谢谢!


|