关系逻辑表达式选择结构45.pptVIP

  • 4
  • 0
  • 约8.83千字
  • 约 45页
  • 2018-07-15 发布于上海
  • 举报
运行结果: y=2 //程序2 #include stdio.h main() { int x=2,y=0; switch (x) { case 1: y++; break; case 2: y++; break; case 3: y++; break; } printf(y=%d\n,y); } 运行结果: y=1 例:比较下面程序的执行结果。(注意break 语句的作用) //程序1 #include stdio.h main() { int x=2,y=0; switch (x) { case 1: y++; case 2: y++; case 3: y++; } printf(y=%d\n,y); } 运行结果: a=2, b=1 例:写出下面程序的执行结果。(嵌套switich语句) #include stdio.h main( ) { int x=1,y=0,a=0,b=0; switch (x) { case 1: switch (y) { case 0: a++; break;//退出本层switch语句 case 1: b++; break;

文档评论(0)

1亿VIP精品文档

相关文档