只得了30分,求助!

P1307 [NOIP2011 普及组] 数字反转

LYX321 @ 2022-08-31 13:59:57


 #include<bits/stdc++.h>
using namespace std;
int main(){
    int z,x;
    cin>>z;
    if(z<0){
        cout<<"-";
        z=abs(z);
    }
    if(z==0){
        cout<<"0";
        return 0;
    }
    for(;z>0;){
        x=z%10;
        cout<<x;
        if(x==0){
            cout<<"\b";
        }
        z=z/10;
    }
    return 0;
}

by w9y3c6 @ 2022-08-31 14:06:13

@LYX321 这个程序的问题在与它根本不会输出0,你试试123033这个数


by LYX321 @ 2022-08-31 14:08:19

@w9y3c6 这个问题解决了,但是还是30分


by w9y3c6 @ 2022-08-31 14:20:30

@LYX321 把新代码贴出来


by leoqing @ 2022-08-31 15:09:03

求关注

#include <bits/stdc++.h> 
using namespace std;
int main()
{
  int n;  cin>>n;   
  if(n<0) {cout<<"-";n=-n;}  
  if(n%10==0) {n=n/10;}  
  int sum=0;   
  while(n!=0)
  {
        int k=n%10;
    sum=sum*10+k;   
    n=n/10;  
  }
  cout<<sum<<endl;
  return 0;
} 

by w9y3c6 @ 2022-08-31 15:36:19

@leoqing 查重率114514%)(无恶意)


by LYX321 @ 2022-09-11 14:06:53

@leoqing 栓Q!


|