资源描述
Click to edit Master title style,24,Second level,Third level,Fourth level,Fifth level,*,Chapter 3*,*,3,第3章,JAVA,语句,空语句:,for,(,int,i,=,1;,i,=,1000;,i+);,表达式语句:,x+;,x=10;,x=10+(y=10);,块语句:,int,t=10;,x=t2;,标号语句::,1,Chapter 3*,表达式语句及示例,2,Chapter 3*,选择语句,语法格式:,if(),举例:,if,(x%2,=,0),System.out.println(x+,是偶数,);,3,Chapter 3*,if-else,语句,语法格式:,if(),else,举例:,if,(x%2,=,0),System.out.println(x+,是偶数,);,else,System.out.println(x+,是奇数,);,4,Chapter 3*,If-else,语句流程图,5,Chapter 3*,循环语句(,while),语法格式:,while(),举例:从1到100的加和,8,Chapter 3*,循环语句(,do-while),语法格式:,do,while();,举例:从1到100的加和,9,Chapter 3*,循环语句(,for),语法格式:,for(;,;,),举例:从1到100的加和,10,Chapter 3*,跳转语句(,return),语法格式:,return();,举例:求,n,的阶乘,n!,11,Chapter 3*,跳转语句(,break),语法格式:,break();,作用:结束包含它的最内层循环语句,使程序跳转到后面的语句继续执行,12,Chapter 3*,跳转语句(,continue),语法格式:,continue();,作用:结束循环体的本次执行,准备进入循环体的下一次执行,13,Chapter 3*,小结,分支:,if-then-else;,循环:,while;for;,转移:,return;break;continue,14,Chapter 3*,作业,P68:2,编程题,1,2,5,7,8,9,10,11,14,15,15,Chapter 3*,
展开阅读全文