第二章
一.选择题
1.C 2.B D 3.A 4.A 5. D 6.C 7.D 8.C 9.A 10.D 11.B 12.D 13.C 14.D 15.A 16.B 17.A 18.B 100011 001111 二.判断题 1.错 2.错 3.错 4.错
三.填空题 1. B 66
2. n1=%d\\nn2=%d\\n 3. 0 四.计算 1
(1) x|y = 0x002f (2) x^y = 0x0026 (3) x&y = 0x0009; (4) ~x+~y = 0xffc6 (5) x<<=3 0x0068 (6) y>>=4 0x0002 2 (1) 6 (2) 50 (3) 1 (4) –16 (5) 1 (6) 20 3 (1) 0 (2) 1 (3) 1 (4) 4 (5) 8 (6) 1 4
(1) 12 (2) 0 (3) 1 (4) 27
(5) 1 (6) 6 (7) 24 (8) 27 (9) –29 5 (1) 0 (2) 1 (3) 1 (4) –3 (5) 2
五.程序分析题 程序1
b=20 a=3600
程序2
一.填空题 1.s=6 2.96
3.(1) scanf(\
(2) c-32 更好的答案:c-('a'-'A') 2.1 main() {
int a,b;
printf(\scanf(\
printf(\} 2.2
int max(int x,int y); main() {
int a,b,c,max;
printf(\scanf(\max=a>b?a:b;
max=c>max?c:max;
printf(\} 2.3
第三章
main() {
int i=0,sum=0; while(i<=100) {
sum+=i; i++; }
printf(\} 2.4 main() {
int i;
int a=10,b=-3; int c;
printf(\ for(i=2;i<10;i++) {
c=3*b+a;
printf(\ a=b; b=c; }
printf(\} 2.5 main() {
int i; while(1) {
printf(\ scanf(\ if(i==0) break; if(i%2==0)
printf(\ else
printf(\ } } 2.6
#include
main() {
int i;
int a=8,b=1; int sum=0;
for(i=0;i<10;i++) {
b+=3; sum += a; a+=b;
printf(\ b:?\\n\ }
printf(\} 2.7
#include
float x,y;
printf(\ scanf(\ if(x<1.0) y=x; else if(x<10) y=2*x-1; else
y=3*x-11;
printf(\} 2.8
#include
long a,i,b,a1; while(1) {
printf(\ scanf(\ printf(\ if(a<=0||a>=100000) break; i=0; a1=0;
while(a!=0) {
b=a;
printf(\ a/=10; i++;
a1=a1*10+b; }
printf(\ i:%ld a1:%ld\\n\ } } 2.9
#include
main() {
int a,b,i,k=0; randomize();
a=random(1001);/*create a random data(0-1000)*/ for(i=0;i<20;i++) {
printf(\ scanf(\ if(a>b) {
k++;
printf(\
}
else if(a
k++;
printf(\ } else {
printf(\ printf(\ break; } }
if(k==20)