#26808: 求救! line4有問題

#### df8077616@gmail.com (亞森)

School : No School
ID : 147797
2021-09-12 16:40:19
a013. 羅馬數字 -- | From: [203.77.42.121] | Post Date : 2021-08-25 21:52

dict1={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
dict2=dict(zip(dict1.values(),dict1.keys()))
appear=""
while True:
number=input("").split(" ")
if number == ["#"]:
break
n1=list(number[0])
n2=list(number[1])
for i in range (len(n1)-1):
if dict1[n1[i]]<dict1[n1[i+1]]:
else:
for i in range (len(n2)-1):
if dict1[n2[i]]<dict1[n2[i+1]]:
else:
else:
print("ZERO")
else:
time=0
while True:
else:
break
while True
if time>0:
time-=1
appear+="M"
else:
break
time=0
while True:
else:
break
while True:
if time ==4:
appear+="CD"
time-=4
if time == 9:
appear+="CM"
time-=9
if time>=5:
time-=5
appear+="D"
if time>0:
time-=1
appear+="C"
else:
break
time=0
while True:
else:
break
while True:
if time ==4:
appear+="XL"
time-=4
if time == 9:
appear+="XC"
time-=9
if time>=5:
time-=5
appear+="C"
if time>0:
time-=1
appear+="X"
else:
break
while True:
appear+="IV"
appear+="IX"
appear+="V"
appear+="I"
else:
break
print(appear)

#26813: Re:求救! line4有問題

#### cges30901 (cges30901)

School : No School
ID : 30877
2022-01-26 17:32:38
a013. 羅馬數字 -- | From: [39.10.227.30] | Post Date : 2021-08-26 11:29

dict1={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
dict2=dict(zip(dict1.values(),dict1.keys()))
appear=""
while True:
number=input("").split(" ")
if number == ["#"]:
break
n1=list(number[0])
n2=list(number[1])
for i in range (len(n1)-1):
if dict1[n1[i]]<dict1[n1[i+1]]:
else:
for i in range (len(n2)-1):
if dict1[n2[i]]<dict1[n2[i+1]]:
else:
else:
print("ZERO")
else:
time=0
while True:
else:
break
while True
if time>0:
time-=1
appear+="M"
else:
break
time=0
while True:
else:
break
while True:
if time ==4:
appear+="CD"
time-=4
if time == 9:
appear+="CM"
time-=9
if time>=5:
time-=5
appear+="D"
if time>0:
time-=1
appear+="C"
else:
break
time=0
while True:
else:
break
while True:
if time ==4:
appear+="XL"
time-=4
if time == 9:
appear+="XC"
time-=9
if time>=5:
time-=5
appear+="C"
if time>0:
time-=1
appear+="X"
else:
break
while True:
appear+="IV"
appear+="IX"
appear+="V"
appear+="I"
else:
break
print(appear)

1. 你的appear沒有在每個測資間清空，會變得越來越長。你可以把appear=0放在while迴圈裡面

2.

if time>=5:
time-=5
appear+="C"

#27085: Re:求救! line4有問題

#### df8077616@gmail.com (亞森)

School : No School
ID : 147797