C语言程序设计第3章解读.pptVIP

  • 7
  • 0
  • 约 86页
  • 2016-03-07 发布于湖北
  • 举报
3.6 习题三 ● 单项选择题   10)以下程序的运行结果为____. #include stdio.h main( ) { int a=2,b=10; printf(a=%%d,b=%%d\n, a,b); } A)a=%2,b=%10 B)a=2,b=10 C)a=%%d,b=%%d D)a=%d,b=%d D 3.3 多分支结构 3.3.2  多分支结构综合举例   (3) 使用if~else形式编程: #include stdio.h main( ) { float x,y; scanf(“%f”,x); if(x0) y=0; else if(x10) y=x; else if(x20) y=10; else if(x40) y=0.5*x+20; else y=40+x; printf(“y=%5.2f\n”,y); } 3.3 多分支结构 3.3.2  多分支结构综合举例   (4) 使用switch语句编程:#include stdio.h main( ) { float x,y; int z; scanf(“%f”,x); z=(int)(x/10); if(x0) z= -1; switch (z) { case –1: y=0; b

文档评论(0)

1亿VIP精品文档

相关文档