#23649: 求救 Python 一直RE


sam931103 (Yeshen)

學校 : 不指定學校
編號 : 138400
來源 : [27.242.34.108]
最後登入時間 :
2021-11-18 22:06:26
c461. apcs 邏輯運算子 (Logic Operators) -- apcs | From: [110.30.7.45] | 發表日期 : 2020-12-05 20:54

請問是哪裡有錯嗎?

  N = input("").split(" ")

  a = N[0]

  b = N[1]

  c = N[2]

  Result = 0 

  if c == 1:

    if a and b:

      Result += 1 

      print("AND")

    if a or b:

      Result += 1

      print("OR")

    if a ^ b:

      Result += 1

      print("XOR")

  elif c == 0:

    if not a and b:

      Result += 1 

      print("AND")

    if not a or b:

      Result += 1

      print("OR")

    if not a ^ b:

      Result += 1

      print("XOR")

  if Result == 0:

    print("IMPOSSIBLE")

 
#24832: Re:求救 Python 一直RE


hsugoya@gmail.com (Мигает cf4?)

學校 : 國立臺北科技大學
編號 : 139476
來源 : [218.172.15.43]
最後登入時間 :
2023-09-07 11:23:36
c461. apcs 邏輯運算子 (Logic Operators) -- apcs | From: [36.224.212.16] | 發表日期 : 2021-03-28 19:39

請問是哪裡有錯嗎?

.

.

.

 

 

 

1.

    你的程式會RE可能的原因是縮排,

    因為你的程式縮的亂7八糟的

2.

然後你的程式得分應該是

    NA (score:10%)

    答對第5筆測資而已喔

問題是你在輸入的時候

並沒有把輸入轉成int

導致if判定a,b,c是字串str 而非int

而 '1'  != 1

Result永遠都是0

故所有輸出永遠都是  IMPOSSIBLE (所以第5筆測資是 IMPOSSIBLE !!)

照你的程式來看:

a = N[0]

b = N[1]

 

c = N[2]

後面要再加上

a=int(a)

b=int(b)

c=int(c)

但其實應該在輸入時就放在a b c 裡面就好了

不用j麼麻煩啦

 

 

以上大概就是我的想法啦

如果還有其他地方我沒遺漏的

歡迎大+補充

謝謝

 
ZeroJudge Forum