討論串[閒聊] 不使用if的寫法
共 18 篇文章

推噓2(2推 0噓 1→)留言3則,0人參與, 最新作者johnny1972 (傻蛋)時間12年前 (2013/01/04 18:17), 編輯資訊
0
0
0
內容預覽:
const char *ans[] = { "no", "yes" };. int i = 1;. int j = ( i == 1 );. printf( ans[j] );. --. 發信站: 批踢踢實業坊(ptt.cc). ◆ From: 111.250.147.21.

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者LaPass (LaPass)時間12年前 (2013/01/04 17:04), 編輯資訊
0
0
0
內容預覽:
JAVA可以這樣. int i=1;. Map map =new HashMap();. map.put(0,"no");. map.put(1,"yes");. for(int j=2;j<65535;j++) map.put(i,"no");. print(map.get(i));. 期她看要可
(還有11個字)

推噓5(5推 0噓 4→)留言9則,0人參與, 最新作者stanwu (stanwu)時間12年前 (2013/01/03 23:27), 編輯資訊
0
0
0
內容預覽:
Hi 各位大大. 這應該算是骨灰級的老問題了. int i = 1;. if ( i == 1 ). printf ("yes");. else. printf ("no");. PS: 可彈性調整 i 裡面的值 0-65535. 如果改寫成 完全拋棄不使用 if 或是 ? : 之類的判斷式, 有其