[問題] c語言的判斷式問題

看板C_and_CPP (C/C++)作者 (羽嵐)時間15年前 (2011/02/09 21:16), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) c 問題(Question): 99高大計算機概論考題 Complete the following C statement so that the value of X will be 2 if it is 0 before executing the statement, and it will be 0 if it is 2 before the execution. X = ; 我自己是這樣寫的x=(x+2 == 2) ?2 :0 可題目寫說before the execution 這樣到底對不對啊??? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.254.115.21

02/09 21:20, , 1F
x=x^2
02/09 21:20, 1F

02/09 21:22, , 2F
它沒說x是其他值的情形,應該沒差吧
02/09 21:22, 2F

02/09 21:52, , 3F
好奇 如果X原本不是0也不是2 依題義運算後的X應該是?
02/09 21:52, 3F

02/09 22:31, , 4F
x = 2 - x;
02/09 22:31, 4F
文章代碼(AID): #1DKfEjzP (C_and_CPP)
文章代碼(AID): #1DKfEjzP (C_and_CPP)