为什么全WA呢...

P5705 【深基2.例7】数字反转

LKY2002 @ 2020-08-04 22:34:58

如下

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[1001];
int main()
{  
    gets(s);
    int i=strlen(s)-1;
    while(i>=0)
        cout<<s[i--];
 } 

by Andysun06 @ 2020-08-04 22:35:57

不建议用gets


by LKY2002 @ 2020-08-04 22:39:38

@Andysun06 啊那为什么全爆啊...


by Andysun06 @ 2020-08-04 22:42:33

@LKY2002 先把gets改了吧


by pomelo_nene @ 2020-08-04 22:44:46

翻转后有前导和后导零。


by Sya_Resory @ 2020-08-04 22:46:00

@SyadouHayami 读题啊。。。没有前导后导0


by a_xiao @ 2020-08-05 16:45:10

直接用数组存余数不是更容易吗?


by john9925 @ 2020-08-06 13:51:48

用scanf


by Assassin_0619 @ 2020-08-07 15:36:58

pascal凑合着用吧,c++l懒得打


var l,i:integer;
s:string;
begin
readln(s);
l:=length(s);
for i:=l downto 1 do
write(s[i]);
end.

|