4个选择题,考考你!
1.已知条件表达式“(n)?(c++):(c--)”,下列表达式中与表达式(n)等价的是
A) (n==0) B) (n==1) C) (n!=0) D) (n!=1)
2.执行下列程序段后 x 的值是
int a=b=c=0, x=35;
if (!a) x--;
else if (b);
if (c) x=3;
else x=4;
A) 3 B) 4 C) 34 D) 35
3. 下列程序执行后的输出结果是
#include <stdio.h>
main() {
int a=1,b=2,c=3,d=0;
if (a==1 && b++==2)
if (b!=21 && c--!=3)
printf("%d, %d, %d \n", a, b, c);
else printf("%d, %d, %d \n", a, b, c);
else printf("%d, %d, %d \n", a, b, c);
}
A) 1, 2, 3 B) 1, 3, 2 C) 1, 3, 3 D) 3, 2, 1
4. 下列程序执行后的输出结果是
#include <stdio.h>
char fun(char x , char y) {
if(x)
return y;
}
main( ) {
int a='9', b='8', c='7';
printf("%c\n", fun(fun(a,b) ,fun(b,c) ));
}
A) 函数调用出错 B) 9 C) 8 D) 7