[问题] 几题问题

楼主: hopeandhmm (......)   2015-04-20 16:40:42
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
谢谢大家的解答
作者: x000032001 (版废了该走了)   2015-04-20 16:51:00
要不要改发CodeJob版
作者: MOONRAKER (㊣牛鹤鳗毛人)   2015-04-20 17:10:00
改发+1
作者: littleshan (我要加入剑道社!)   2015-04-20 17:20:00
看到这种面试问题就让我警铃大作 XD为什么swap integer不能用第三个变量?为什么一定要用macro?为什么检查pot只能写一行?这些比较像是考奇技淫巧,而不是检验对方的工程观念了
作者: RealJack   2015-04-20 17:40:00
第一题参考: int a,b; a^=b; b^=a; a^=b;
作者: Ebergies (火神)   2015-04-20 18:33:00
第一题不是 a, b = b, a 吗
作者: Feis (永远睡不着 @@)   2015-04-20 18:38:00
应该是 swap(a, b) 吧?
作者: fireslayer (fireslayer)   2015-04-20 19:20:00
Mtk的题目....我觉得没什么意义
作者: Jimmy0301 (Jimmy)   2015-04-20 19:24:00
应该网络上可以找到答案吧
作者: BlazarArc (Midnight Sun)   2015-04-21 00:29:00
marco /facepalm
作者: MOONRAKER (㊣牛鹤鳗毛人)   2015-04-21 03:50:00
marco polo
作者: steve1012 (steve)   2015-04-21 21:10:00
google找的到

Links booklink

Contact Us: admin [ a t ] ucptt.com