100分 Subtask #1

P1307 [NOIP2011 普及组] 数字反转

nobody_here @ 2024-08-11 06:59:28

#include<bits/stdc++.h>
using namespace std;
string a;
long long i,x=0;
void yy(){
    if(a[i]=='0'){
        i--;
        return yy();
    }
}
int main(){
    cin>>a;
    i=a.length()-1;
    if(a[0]=='-'){
        cout<<"-";
        x=1;
    }
    if(a[i]=='0'){
        yy();
    }
    for(i;i>=x;i--){
        cout<<a[i];
    }
    return 0;
}

by nobody_here @ 2024-08-11 07:03:47

结贴


|