C语言习题集及答案 下载本文

5. (1) #include “stdio.h”

(2) int n (3) getchar()

(4) c-?0? 或者c-48

(5) “%c,%d\\n”

第三单元 分支程序设计 一、 选择题 1. C 2. EB 3. D 4. C 5. D 6. C 7. D 8. C 二、 读程序写结果

1. 1,0,3 2. 200 3. 01 4. 1 7 0

5. It is B. It is C.other. 6. a=2,b=1 三、 填空

1. 0 2. 1

3. (1) y=2*x+3

(2)else if(x==0) (3)else

4. (1) #include “math.h”

(2) float a,b,c,s,s1

(3) (a+b>c)&&(b+c>a)&&(c+a>b) (4) sqrt(s1) (5) else 5. (1) b!=0

(2) c!=0 (3) d>=0 (4) (2*a) (5) (2*a)

(6) pi=sqrt(-d)/(2*a) 6. (1) switch(c)

(2) break

24

(3) break (4) default

第四单元 循环程序设计 一、 选择题

1. D 2. A . 3. B . 4. C 5. A 6. D 二、 读程序写结果

1. 1

2 3

2. i=0,s=1

i=1,s=4 i=2,s=9 i=3,s=16 3. m=4

m=10 m=22 m=46 m=94 4. (1) quert

(2) rvfsu (3) quert? 5. <><><># 6. a=5

7. 2 5 8 11 14 8. (0,0), (1,0),(1,1),

(2,0),(2,1),(2,2),

(3,0),(3,1),(3,2),(3,3), 9. ******

****** ******

****** ****** ******

25

10. 11 13 17 19 23 29 三、 填空

1. switch、循环 2. (1)s=0

(2)i=i+2 3. (1) x<=9

(2) y<=9 (3) z=0 (4) z<=9

(5) x*100+y*10+z 4. (1) n

(2) Tn+a (3) Sn+Tn (4) count++ 5. (1) 10

(2) Sn+hn*2 (3) hn/2 6. (1) 3

(2) 2*i

(3) printf(“\\n”); (4) i (5) 4-2*i 7. (1) station

(2) i+1 (3) total+2

26