subtask WA,求条

P1307 [NOIP2011 普及组] 数字反转

xiozhi @ 2024-11-10 11:22:34

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    bool flag=0;
    cin>>n;
    if(n<0){
        n=-n;
        cout<<"-";
    }
    while(1){
        if(n%10!=0){
            cout<<n%10;
            flag=1;
        }
        else{
            if(flag==1)
                cout<<n%10;
        }
        n=n/10;
        if(n==0)
            break;
    }
    return 0;
}

by qi_ya_wish @ 2024-11-12 20:10:02

@xiozhi

#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 xiozhi @ 2024-11-12 20:16:25

哈哈呵呵


by takej233 @ 2024-11-14 13:08:55

@xiozhi你是不是少判断了0这个测试点,你输入0看结果是不是0,我就因为忘记判断这个极端点100分无法ac


|