13. int[] a=new int[]{310,250,120}; int price=a[2]; Console.Write("{0}", (price<100 ? "便宜" : ( price < 150 ? "可接受" : "好貴")));上述程式會顯示什麼訊息?
(A)便宜
(B)可接受
(C)程式當掉
(D)好貴

答案:登入後查看
統計: A(3), B(28), C(1), D(3), E(0) #3228016

詳解 (共 1 筆)

#6209745
13. int[] a=new int[]{310,250,120}; int price=a[2];
Console.Write("{0}", (price<100 ? "便宜" : ( price < 150 ? "可接受" : "好貴")));上述程式會顯示什麼訊息?
*陣列取得的結果為120
*120比100小為false,false會跳到三元判斷的冒號後面
*120小於150為true,訊息顯示可接受。答案為B
0
0