当不知道执行次数的时候选择while循环
package ST.student.Day228;
//打印9*9乘法表
public class Demo01 {
public static void main(String[] args) {
out: for (int i = 1 ;i<=9;i++){
for (int j = 1; j <=i ; j++) {
//System.out.print(j+"*"+i+"="+i*j+"\t");
if (j==5){
//break;是退出当前循环
//break out;//退出标记的循环
//continue 后面的代码不执行,跳到外面继续执行下一次循环
//continue out;后面的代码不执行,继续执行标记的循环
continue;
}
System.out.print(j+"*"+i+"="+i*j+"\t");
}
System.out.println();
}
}
}
package ST.student;
import java.util.Scanner;
public class Demo3 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double x=scanner.nextDouble();
double X=x(x,1000);
System.out.println(X);
}
public static double x(double a,double b){
return b-a;
}
}