[問題] 幾題問題

看板C_and_CPP (C/C++)作者 (......)時間11年前 (2015/04/20 16:40), 11年前編輯推噓7(707)
留言14則, 10人參與, 最新討論串1/1
P幣2000 因為要去面試公司 而C/C++都快忘了 上來求救一下幾題 1. Write a code to swap integer a, b, without temporary variable. 2. Write 3 function: a) set a bit. b) clear a bit, c) inverse a bit. 3. Write a MARCO to calculate the square of integer a. 4. Write one line expression to check if a integer is power of 2 5. Write a function to find the middle field of singled-linked list with ou 6. Write a code to reverse the linked list. For example: [0] -> [n], [1] -> 7. Find the possible error Int ival; Int **p; Ival = *p; 8. What is the possible error of below SQR function. int SQR(volatile int *a) { return (*a)*(*a); } 另外還有圖片上的 http://i.imgur.com/OVd5WL7.jpg
http://i.imgur.com/3ROeg8Q.jpg
謝謝大家的解答 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.20.129 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1429519244.A.2BC.html ※ 編輯: hopeandhmm (223.136.248.152), 04/20/2015 16:49:15

04/20 16:51, , 1F
要不要改發CodeJob版
04/20 16:51, 1F

04/20 17:10, , 2F
改發+1
04/20 17:10, 2F
※ 編輯: hopeandhmm (140.112.20.129), 04/20/2015 17:12:14

04/20 17:20, , 3F
看到這種面試問題就讓我警鈴大作 XD
04/20 17:20, 3F

04/20 17:20, , 4F
為什麼swap integer不能用第三個變數?
04/20 17:20, 4F

04/20 17:22, , 5F
為什麼一定要用macro?為什麼檢查pot只能寫一行?
04/20 17:22, 5F

04/20 17:23, , 6F
這些比較像是考奇技淫巧,而不是檢驗對方的工程觀念了
04/20 17:23, 6F

04/20 17:40, , 7F
第一題參考: int a,b; a^=b; b^=a; a^=b;
04/20 17:40, 7F

04/20 18:33, , 8F
第一題不是 a, b = b, a 嗎
04/20 18:33, 8F

04/20 18:38, , 9F
應該是 swap(a, b) 吧?
04/20 18:38, 9F

04/20 19:20, , 10F
Mtk的題目....我覺得沒什麼意義
04/20 19:20, 10F

04/20 19:24, , 11F
應該網路上可以找到答案吧
04/20 19:24, 11F

04/21 00:29, , 12F
marco /facepalm
04/21 00:29, 12F

04/21 03:50, , 13F
marco polo
04/21 03:50, 13F

04/21 21:10, , 14F
google找的到
04/21 21:10, 14F
文章代碼(AID): #1LDBkCAy (C_and_CPP)
文章代碼(AID): #1LDBkCAy (C_and_CPP)