为什么不行??(C++)

P1307 [NOIP2011 普及组] 数字反转

Aoxiangcar @ 2023-08-01 14:13:38

#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string n;
    int a;
    cin>>n;
    a=n.size()-1;
    if(n.size()==1)
    {
        cout<<n[0];
        return 0;
    }
    if(n[a]=='0')
    n[a]='?';
    for(int i=0;i<n.size();i++)
    {
        if(n[i]=='-')
        cout<<n[i];
        else
        {
            if(n[a]!='?')
            cout<<n[a];
        }
        a--;
    }
    return 0;
}

by wzc_IOI_czl @ 2023-08-01 14:25:40

100


|