50fps

P1307 [NOIP2011 普及组] 数字反转

Ac_Code_cn_com @ 2023-08-26 20:36:02

#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    if(a[0]=='0'){
        cout<<a;
        return 0;   
    }
    if(a[0]=='-'){
        cout<<'-';
        if(a[a.size()]==0&&a.size()>1){
            for(int i=a.size()-2;i>0;i--){
                cout<<a[i];
            }       
        }else{
            for(int i=a.size()-1;i>0;i--){
                cout<<a[i];
            }   
        }
    }else{
        if(a[a.size()]==0&&a.size()>1){
            for(int i=a.size()-2;i>=0;i--){
                cout<<a[i];
            }       
        }else{
            for(int i=a.size();i>=0;i--){
                cout<<a[i];
            }   
        }
    }
    return 0;
}

by FurippuWRY @ 2023-08-26 20:39:34

@WQJ111213 kkwd

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int a,b=0;
    cin>>a;
    if(a<0){
    cout<<"-";
    a=abs(a);}
    if(a==0){
    cout<<a;
    return 0;}
    else while(a!=0){
        b=b*10+a%10;
        a=a/10;
    }
    cout<<b;
    return 0;
}

(什么fps啊是pts吧


by Ac_Code_cn_com @ 2023-08-26 20:42:01

@FurippuWRY 所以我为什么错


by FurippuWRY @ 2023-08-26 20:43:51

@WQJ111213 0没清干净,比如输入114514000,输出00415411


|