70分求助

P1307 [NOIP2011 普及组] 数字反转

```cpp if(a[i]!='0') printf("%c", a[i]); `````` 它因该只是要你去前导零,你这是把0全去了吧?
by willJ @ 2023-09-01 20:08:42


-103 试试
by Rieman_sum @ 2023-09-01 20:09:02


@[TheWindbell](/user/1057556)
by willJ @ 2023-09-01 20:13:57


@[willJ](/user/826138) **谢谢!** 最终代码: ```cpp #include <bits/stdc++.h> #define maxn 20 char a[maxn]; int main() { scanf("%s", &a); if(!strcmp(a, "0")) { printf("0"); return 0; } if(a[0]=='-') printf("-"); int mul = 1; for(int i=strlen(a)-1; i>=(a[0]=='-'); i--) { mul *= (a[i]=='0'); if(mul==0) printf("%c", a[i]); } return 0; } ```
by TheWindbell @ 2023-09-01 21:48:05


@[Guo1](/user/743879) **多谢提醒!**
by TheWindbell @ 2023-09-01 21:48:44


|