Redian新闻
>
有没有21寸到32寸之间的显示器
avatar
有没有21寸到32寸之间的显示器# PDA - 掌中宝
d*x
1
只能使用 ! ~ & ^ | + << >>
可以用 =,可定义局部变量,字长32bit,右移是算数右移,不许cast
常量只能在0~0xff之间。实际上一般面试不会有这个约束,就忽略吧
1. int isAsciiDigit(int x);
如果x是'0'~'9',返回1,否则返回0
2.int anyEvenBit(int x);
如果任何偶数位上有1返回1 (1 --> 1, 2 --> 0)
3.int copyLSB(int x);
如果x & 1,则返回0xffffffff,否则返回0
4.int leastBitPos(int x);
5.int divpwr2(int x, int n);
输出 x / pow(2, n);,n非负。
6.int conditional(int x, int y, int z);
相当于x ? y : z
7.int isNonNegative(int x);
非负数返回1
8.int isGreater(int x, int y);
如果x > y,返回1
9.int absVal(int x);
返回x的绝对值
10.int isPower2(int x);
如果x是pow(2, n),则返回1.对于所有负数返回0
11.int bitCount(int x);
返回x的2进制表示的1的个数。
因为作业due已经过去很久了所以应该没啥policy问题。。
至今最少的操作符个数是
1.6 2.7 3.2 4.3 5.6 6.6 7.2 8.8
9.3 10.7 11.24
avatar
t*e
2
有hdmi接口,有声音输出
这样接个安竹棒,挂在厨房可以看youtube
★ 发自iPhone App: ChineseWeb 7.8
avatar
c*s
3
请问操作符个数怎么算出来的
比方说 5题 不是 x >> n 么?
avatar
A*D
4
买一个32寸的lcd tv也就100来块
avatar
d*x
5
如果x是负数。。。

【在 c**s 的大作中提到】
: 请问操作符个数怎么算出来的
: 比方说 5题 不是 x >> n 么?

avatar
c*t
6
mark, 有空都练一下。
第二题 应该是(1-->0, 2-->1)吧?

【在 d**********x 的大作中提到】
: 只能使用 ! ~ & ^ | + << >>
: 可以用 =,可定义局部变量,字长32bit,右移是算数右移,不许cast
: 常量只能在0~0xff之间。实际上一般面试不会有这个约束,就忽略吧
: 1. int isAsciiDigit(int x);
: 如果x是'0'~'9',返回1,否则返回0
: 2.int anyEvenBit(int x);
: 如果任何偶数位上有1返回1 (1 --> 1, 2 --> 0)
: 3.int copyLSB(int x);
: 如果x & 1,则返回0xffffffff,否则返回0
: 4.int leastBitPos(int x);

avatar
l*1
7
mark
avatar
h*n
8
挺难的,瞎做了一些,没完全按照要求做
1. int isAsciiDigit(int x);
如果x是'0'~'9',返回1,否则返回0
2.int anyEvenBit(int x);
如果任何偶数位上有1返回1 (1 --> 1, 2 --> 0)
static const int mask = 0x55555555;
return (mask & x) != 0 ? 1 : 0;
3.int copyLSB(int x);
如果x & 1,则返回0xffffffff,否则返回0
return (x<<31)>>31;
4.int leastBitPos(int x);
return x&(~x+1);
5.int divpwr2(int x, int n);
输出 x / pow(2, n);,n非负。
6.int conditional(int x, int y, int z);
相当于x ? y : z
return (~!x+1)&(z) + (~!!x+1)&(y) ;
x !x !!x
0 1 0
非零 0 1
x ~!x+1 ~!!x+1
0 -1 0
非零 0 -1
7.int isNonNegative(int x);
非负数返回1
return !(x>>31&0x01);
8.int isGreater(int x, int y);
如果x > y,返回1
int z = x - y;
return x-(z>>31&0x01)*(x-y);
9.int absVal(int x);
返回x的绝对值
return x>>31&0x01 ? ~x + 1 : x;
10.int isPower2(int x);
如果x是pow(2, n),则返回1.对于所有负数返回0
return x&&!(x&(x-1))&&!(x>>31&0x01) ? 1 : 0;
11.int bitCount(int x);
int i=0;
while(x)
{
i++;
x &= (x-1);
}
return i;

【在 d**********x 的大作中提到】
: 只能使用 ! ~ & ^ | + << >>
: 可以用 =,可定义局部变量,字长32bit,右移是算数右移,不许cast
: 常量只能在0~0xff之间。实际上一般面试不会有这个约束,就忽略吧
: 1. int isAsciiDigit(int x);
: 如果x是'0'~'9',返回1,否则返回0
: 2.int anyEvenBit(int x);
: 如果任何偶数位上有1返回1 (1 --> 1, 2 --> 0)
: 3.int copyLSB(int x);
: 如果x & 1,则返回0xffffffff,否则返回0
: 4.int leastBitPos(int x);

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。