C语言程序设计试题集及其答案 下载本文

内容发布更新时间 : 2024/11/13 3:50:03星期一 下面是文章的全部内容请认真阅读。

int main() { int a;

printf(\ scanf(\

_____________________________________________ {

case 1:printf(\

_____________________________________________ printf(\

case 3:printf(\ case

4:printf(\_________

case 5:printf(\ case 6:printf(\ case 7:printf(\

_____________________________________________ printf(\ }

return 0; }

5. 判断a>b、a

#include\ int main() { int a,b;

printf(\ scanf(\

_____________________________________________ printf(\

_____________________________________________ printf(\

_____________________________________________ printf(\

_____________________________________________ printf(\≠B\\n\ return 0; }

6. 根据以下函数关系,对输入的每个x值,计算出相应的y值。 #include\ int main ( ) {

int x,c,m; float y;

scanf(“%d”,&x);

_________________________________________c=-1; c=_____________________________________________; switch (c) {

case –1 : y=0 ; break ; case 0 : y=x ; break ; case 1 : y=10 ; break ; case 2 : case

3

:

y=-0.5*x+20

_____________________________________________; default : y=-2 ; }

if (c!=2) printf (“y=%f”,y);

_____________________________________________ printf(“error!”); return 0; } 7.

找出x,y,z三个数中的最小数,并判断该数是否等于b。 #include\ int main() {

int x=4,y=5,z=8 ,b;

else

;

int u,v; scanf(\ u

=

x

?

_____________________________________________ ; v

=

u

?

_____________________________________________;

if_____________________________________________printf (“最小数等于b!\\n”);

_____________________________________________printf (“最小数不等于b!\\n”); return 0; }

8. 输入两个运算数x,y和一个运算符号op,输出该运算结果的值,例如输入3+5↙得到结果8 .

#include\ int main ( ) {

float x,y,r; char op ;

scanf(\ switch (op)