zhuimengNB @ 2024-03-21 20:56:44
n=int(input()) while n!=1: if n%2!=0: print(f"{n}3+1={n3+1}") n= n * 3 + 1 else n%2==0: print(f"{n}//2={n//2}") n= n// 2 print("End")
by xd244 @ 2024-03-21 21:14:43
@zhuimengNB 服了你,else后面还有条件是吧?
n=int(input())
while n!=1:
if n%2!=0:
print(f"{n}3+1={n3+1}")
n= n * 3 + 1
else:
print(f"{n}//2={n//2}")
n= n//2
print("End")
by BGM114514 @ 2024-03-21 21:17:44
@xd244 dalao不是,您也不至于没看题目就直接在人家代码上改吧?
by xd244 @ 2024-03-21 21:17:52
@zhuimengNB 还有你的代码有问题,给你改了一下:
n=int(input())
while n!=1:
if n%2!=0:
print(str(n)+"*3+1="+str(3*n+1))
n=n*3+1
else:
print(str(n)+"/2="+str(n//2))
n=n//2
print("End")
by BGM114514 @ 2024-03-21 21:19:28
@xd244 你这代码能过样例算您牛逼
by xd244 @ 2024-03-21 21:20:24
@BGM114514 AC了(拜托红题一遍都过不了吗?)