作者hopeandhmm (......)
看板C_and_CPP
標題[問題] 幾題問題
時間Mon Apr 20 16:40:42 2015
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
→ x000032001: 要不要改發CodeJob版 04/20 16:51
→ MOONRAKER: 改發+1 04/20 17:10
※ 編輯: hopeandhmm (140.112.20.129), 04/20/2015 17:12:14
推 littleshan: 看到這種面試問題就讓我警鈴大作 XD 04/20 17:20
→ littleshan: 為什麼swap integer不能用第三個變數? 04/20 17:20
→ littleshan: 為什麼一定要用macro?為什麼檢查pot只能寫一行? 04/20 17:22
→ littleshan: 這些比較像是考奇技淫巧,而不是檢驗對方的工程觀念了 04/20 17:23
推 RealJack: 第一題參考: int a,b; a^=b; b^=a; a^=b; 04/20 17:40
推 Ebergies: 第一題不是 a, b = b, a 嗎 04/20 18:33
→ Feis: 應該是 swap(a, b) 吧? 04/20 18:38
推 fireslayer: Mtk的題目....我覺得沒什麼意義 04/20 19:20
推 Jimmy0301: 應該網路上可以找到答案吧 04/20 19:24
推 BlazarArc: marco /facepalm 04/21 00:29
→ MOONRAKER: marco polo 04/21 03:50
推 steve1012: google找的到 04/21 21:10