只有70分,就只有wa没过了,救救孩子吧

P1307 [NOIP2011 普及组] 数字反转

bbluele @ 2023-07-04 16:49:57

#include<iostream>
using namespace std;
int main()
{
    long long x, y, z=0, i;
    cin >> x;
    if (x == 0)
    {
        cout << '0';
    }
    if (x < 0) 
    {
        x = -x;
        cout << "-";
    }  
    while (x != 0)
    {
        if (x % 10 != 0)
            cout << x % 10;
        x /= 10;
    }
}

by lorry26 @ 2023-07-04 16:54:20

AC码

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

by lorry26 @ 2023-07-04 16:56:28

@bbluele


by dsfgsdf @ 2023-07-04 17:08:20

嗨嗨嗨,ac代码来了奥:

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

return 0;

}

by bbluele @ 2023-07-05 13:08:56

@lorry26 谢谢谢谢


|