123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import java.util.Scanner;
- /**
- * ClassName: TestSwitch01
- * Package: PACKAGE_NAME
- * Description:
- *
- * @Author 爱扣钉-陈晨
- * @Create 2023/9/17 10:23
- * @Version 1.0
- */
- public class TestBC07 {
- /*
- break和continue
- */
- public static void main(String[] args) {
- for (int i = 0; i < 5; i++) {
- if (i == 3){
- continue;
- }
- System.out.println(i);
- }
- System.out.println("------------------");
- //猜数字案例 修改
- Scanner scanner = new Scanner(System.in);
- //随机数
- int number = (int) (Math.random() * 100);
- int num = 0;
- while ( true ){
- System.out.println("请输入猜测数字");
- num = scanner.nextInt();
- if (num > number ){
- System.out.println("输入的数字大了");
- }
- if (num < number ){
- System.out.println("输入的数字小了");
- }
- //break
- if (num == number){
- break;
- }
- }
- System.out.println("猜对了:"+num);
- }
- }
|