求指点,为何只有70分?

P1307 [NOIP2011 普及组] 数字反转

醉里挑灯看剑 @ 2018-06-10 19:49:21

include<iostream>

include<cstdio>

include<cmath>

include<cstdlib>

using namespace std; int a[13];
int main() { int n,s=0,flag=0; cin>>n; //if(n>0)cout<<'-'; if(n<0){ cout<<'-'; n=abs(n); } if(n==0) { cout<<'0'; return 0; } while(n>0) { s++; a[s]=n%10; n/=10; } for(int i=1;i<=s;i++) { if(a[i]!=0) { flag=1; cout<<a[i]; } if(a[i]==0&&flag!=1) continue;

} }


by 少帅_zjm @ 2018-06-10 20:02:09

代码能调得好看一点吗?


by 氷スイカ233 @ 2018-06-10 20:18:15

@冷月无声 请在代码前加上```,代码后也加上.

例:

cout<<23333;

by 亚索s @ 2018-07-31 22:04:51

markdown


by Daisy411 @ 2018-08-05 16:05:41

include<iostream>

include<cstdio>

include<cmath>

include<cstdlib>

using namespace std; int a[13]; int main() { int n,s=0,flag=0; cin>>n; if(n<0){ cout<<'-'; n=-n; } if(n==0) { cout<<'0'; return 0; } while(n>0) { s++; a[s]=n%10; n/=10; } for(int i=1;i<=s;i++) { if(a[i]!=0){ flag=1; cout<<a[i]; } if(a[i]==0&&flag!=1) continue;

if(a[i]==0&&flag==1) cout<<a[i];加上这步就对了 } }


|