看板 C_and_CPP 關於我們 聯絡資訊
無聊曬一下短路用法 https://ideone.com/vYvznk #include <cstdio> int f(int i, int j, int k) { return (i > 8) || printf("%d x%2d =%2d%c", i + 1, j + 1, k + i + 1, "\n|"[!(j & 8)]) && f(i + !!(j & 8), "123456780"[j] - '0', -!(j & 8) & (k + i + 1)); } int main() { f(0, 0, 0); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.232.134.137 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1543609306.A.074.html
Hurricaneger: 看不懂 12/01 20:22
longlongint: 樓上 利用邏輯運算子會 jump 的特性當 if else 用 12/03 07:54
longlongint: 但是學這個對找工作沒幫助 otz 12/03 07:56
firejox: 的確沒啥幫助,但加上fold expression的話,可以寫的 12/03 22:11
firejox: 跟迴圈差不多 12/03 22:14
boyou314: 看不懂+1 12/05 16:36
bigload1234: 用goto會很簡單 感覺也不是面試官想看到的答案 12/17 06:03