80分求助

P1307 [NOIP2011 普及组] 数字反转

shiffack @ 2024-08-14 09:05:15

#include <bits/stdc++.h>
using namespace std;
int b,c,d,e,f,g,h,j,k,l,m,n,i,x;
char a[20];
int main()
{
    cin.getline(a,20);
    for(int i=strlen(a)-1;i>=0;i--)
    {
        b=a[i];
        if(a[0]=='-'&&i==strlen(a)-1&&c==0)
        {
            cout<<'-';
            c=1;
        }
        if((b=='0'&&i==strlen(a)-1)||a[i]=='-')
        {

        }
        else cout<<a[i];
    }
    return 0;
}

by Finner_forgeter @ 2024-08-14 09:16:55

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

迪哥无敌


by zhizhenzqs @ 2024-08-14 09:17:59

包过呀


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a;
    if(a<0)
    {
        cout<<'-';
        a=abs(a);
    }
    int w=0;
    for(int q=a;q>0;q/=10)
    {
        w=w*10+q%10;
    }
    cout<<w;

}

by shiffack @ 2024-08-14 09:18:02

@zhizhenyaohanyu 不是?


by yuhongyue @ 2024-08-14 09:18:36

@zhizhenyaohanyu 你手累吗


by jza110228 @ 2024-08-14 09:20:46

@zhizhenyaohanyu 无敌了


by zhizhenzqs @ 2024-08-14 09:21:28


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

int main()
{
    string a;bool j=0;
    cin>>a;
    if(a[0]=='-'){j=1;cout<<'-';}
    for(int i=a.size()-1;i>=
    j;i--)cout<<a[i];
}

by zhizhenzqs @ 2024-08-14 09:23:54

包不过的☻


by shiffack @ 2024-08-14 10:04:45

@zhizhenzqs 感谢 已取关


by zhizhenzqs @ 2024-08-14 10:16:00

@zhizhenwangshengdi cao


上一页 |