diff --git "a/48 \351\251\254\345\256\217\350\276\276/2022125 for \345\276\252\347\216\257.md" "b/48 \351\251\254\345\256\217\350\276\276/2022125 for \345\276\252\347\216\257.md" new file mode 100644 index 0000000000000000000000000000000000000000..96547a2e73965a1451100efe9c4c9f9152051952 --- /dev/null +++ "b/48 \351\251\254\345\256\217\350\276\276/2022125 for \345\276\252\347\216\257.md" @@ -0,0 +1,44 @@ +# while练习 + +```java +import java.util.Scanner; + +public class D1 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入一个数"); + int action = sc.nextInt(); + System.out.println("请再输入一个数"); + int end = sc.nextInt(); + int Counting =0; + int i =action; + while (action num) { + System.out.println("猜大了,再来一次:"); + + } else { + System.out.println("猜小了,再来一次:"); + } + count += 1; + if (count == 3) { + System.out.println("因为你三次机会已经用完了,所以你可以选择y or n 来决定是否继续 "); + System.out.println("重开吧:"); + char action =sc.next().charAt(0); + if (action == 'y'|| action=='Y') { + count = 0; + System.out.println("重新开始!"); + } else { + System.out.println("游戏结束"); + break; + } + } + } + } +} +``` + +```java