Subtask #1 过不了为什么?

P1307 [NOIP2011 普及组] 数字反转

yishanyi @ 2023-08-11 10:29:34

Subtask #1 过不了为什么?

#include<bits/stdc++.h>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[0] == '-') {
        cout << '-';
        s.erase(0, 1);
    }
    reverse(s.begin(), s.end());
    while (s[0] == '0') {
        s.erase(0, 1);
    }
    cout << s;
    return 0;
}

ps:我把去前导0的while去了#1点就能过


by Ew_Cors @ 2023-08-11 10:30:49

@yishanyi 你输入 0 看看。


by yishanyi @ 2023-08-11 10:33:33

@Ew_Cors 感谢


by liquanlinli @ 2023-08-17 15:44:57

@yishanyi 感谢


by TheWindbell @ 2023-09-01 21:31:05

@Ew_Cors 感谢


|