C语言程序设计试题集及其答案

} } 13.

#include int main( ) {

int a=2,b=7,c=5; switch (a>0){

case 1: switch (b<0){

case 1: printf(\ case 2: printf(\ }

case 0: switch (c==5){

case 1: printf(\ default : printf(\ }

default : printf(\ }

printf(\ return 0; }

14. #include

int main() {

int a=0,b=1,c=0,d=20; if(a) d=d-10; else if (!b)

if(!c) d=15; else d=25; printf(\ return 0; } 15. #include int main()

{ int a=1; switch(a){

case 0: printf(\ case 1:printf(\ case 2:printf(\ }

return 0; } 16. #include int main() { int x, y; scanf(\

y = x>12 ? x + 10 : x - 12; printf(\ return 0; } 输入:12<回车>

17. #include int main() {

float x, y; char op; double r;

scanf(\ switch(op)

{ case '+': r = x + y; break; case '-': r = x - y; break; case '*': r = x * y; break; case '/': r = x / y; break; }

printf(\ return 0; } 输入:3.5<回车> 18. #include \ void main( ) {

int a=7; if(a>9 || a<10) a=a/3; else a=a%3; printf(\ }

19. #include void main() {

int a=20; switch(a%3) { case 0: printf(\ case 1: printf(\ case 2: printf(\ default: printf(\ }

printf(\ }

20. #include void main() {

int a=2,b=5,c=8,t;

if ( a < b ) { t = a; a = b; b = t; } if ( b < c ) { t = b; b = c; c = t; } if ( a < b ) { t = a; a = b; b = t; } printf( \ } 解答: 1. 运行结果:

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4