首页 > 试题广场 >

写出具有如下原型的函数的代码: * * Do rotat

[问答题]

写出具有如下原型的函数的代码:

/*
* Do rotating left shift. Assume 0 <= n < w
* Examples when x = 0x12345678 and w = 32:
* n=4 -> 0x23456781, n=20 -> 0x67812345 */
unsigned rotate_left(unsigned x, int n);

函数应该遵循位级整数编码规则。要注意n=0的情况。

这道题你会答吗?花几分钟告诉大家答案吧!