80pts

P1307 [NOIP2011 普及组] 数字反转

DengWenZhangQwQ @ 2024-10-06 11:51:11


#include <bits/stdc++.h>
using namespace std;

long long b;

void just()
{
    long long a[90];
    long long flag=1;
    long long cur;

    if(b>=0)
    {
        cur=1;
    }
    else
    {
        cur=0;
    }

    b=abs(b);

    while(b>0)
    {
        a[flag]=b%10;
        flag++;
        b=b/10; 
    } 

    if(a[1]==0)
    {
        a[1]=-1;
    }

    if(cur==0)
    {
        cout<<"-";
    }
    for(long long i=1;i<=flag-1;i++)
    {
        if(a[i]!=-1)
        {
            cout<<a[i];
        } 
    }
}

int main()
{
    cin>>b;
    if(b==0)
    {
        cout<<0;
        return 0;
    }
    just();

    return 0;
}

by tt12341234 @ 2024-10-06 12:14:48

@171zdw

给个关注呗

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,n;
    cin>>a;
    n=a;
    if(n<1){
        n=-n;
    }   
    if(n%10==0){
        n/=10;
    }
    c=0;
    while(n>0){
        b=n%10;
        c=c*10+b;
        n/=10;
    }
    if (a<0){
        c=-c;
    }
    cout<<c;
    return 0;
}

by DengWenZhangQwQ @ 2024-10-06 13:02:50

@tt12341234 必须的谢谢大佬


by ridewind2013 @ 2024-10-06 20:25:20

#include<bits/stdc++.h>
using namespace std;
int n,s=0;
int main(){
    cin>>n;
    while(n)s=s*10+n%10,n/=10;
    cout<<s;
    return 0;
}

by DengWenZhangQwQ @ 2024-11-17 09:17:06

@ridewind2013 我嘞个李班长 太6了


|