测试点全部RE,求助

P1307 [NOIP2011 普及组] 数字反转

haker546 @ 2023-11-18 21:10:10

list=[]
n=input()
n=int(n)
a=len(n)
x=0
if n<0:
x="-"
for i in range(a):
list.append(n[a-i])
ans=0
for i in range(len(list)):
ans=list[i]*pow(10,len(list)-1)
if n==0:
print(0)
else:
if x==0:
print(ans)
else:
print(x+ans)


by heyx0201 @ 2023-11-18 21:15:00

@haker546 望丰展?使 MD


by haker546 @ 2023-11-21 15:06:32

@heyx0201 额,能问一下是什么意思吗(我是萌新看不懂啊啊啊!!!! )


by heyx0201 @ 2023-11-21 20:53:42

@haker546


by haker546 @ 2023-11-24 07:11:05

list=[]
n=input()
n=int(n)
a=len(n)
x=0
y=0
if n!=0:
    #以下
    if n<0:
        x="-"
    for i in range(a):
        list.append(n[a-1-i])
    ans=0
    #以上为数字重组部分
    for i in range(len(list)):
        y=str(list[i])
        ans+=y
    if x==0:
        print(ans)
    else:
        print(x+ans)
else:
    print(0)

by stephen66 @ 2023-11-25 23:02:00

我去,python


|