问题
单项选择题
若有如下定义:
int x=6,y=3,z=2;
则表达式x=y||y<z&&z==z的值是( )。
A.0
B.1
C.4
D.6
答案
参考答案:B
解析: <优先级高于==高于&&高于||高于=。首先计算表达式y<z的值,y<z为假,表达式的值为0,则逻辑表达式y<z&&z= =z的值也为0,||左侧y的值为非零值3,所以表达式的值为1,将1赋值给x,赋值表达式的值是1。
若有如下定义:
int x=6,y=3,z=2;
则表达式x=y||y<z&&z==z的值是( )。
A.0
B.1
C.4
D.6
参考答案:B
解析: <优先级高于==高于&&高于||高于=。首先计算表达式y<z的值,y<z为假,表达式的值为0,则逻辑表达式y<z&&z= =z的值也为0,||左侧y的值为非零值3,所以表达式的值为1,将1赋值给x,赋值表达式的值是1。
阅读理解。 | ||
Good morning! Welcome to our food shop. We have many things on sale. Please come in and have a look! Please look at our ads(广告).Would you like some of them? Some food isn’t on the ads, such as(如)chicken and fish. The chicken is $20 a kilo and the fish is $25 a kilo.
| ||
( )1. The ads are for a clothes shop. ( )2. Mrs Green can buy three kilos of eggs with $15.00. ( )3. You have only $7.00,and you can buy three bottles of orange juice ( )4. You have $60.00 now.You can buy 15 kilos of apples or 2 bags of rice. ( )5. Fish isn’t on the ads, but we can buy it in the shop. |