Auto commit

上级 5b0ce43e
class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
import java.util.Random;
import java.util.Scanner;
public class demo10 {
public static void main(String[] args) {
Random r=new Random();
int num=r.nextInt(100)+1;
Scanner sc=new Scanner(System.in);
while(true){
System.out.println("请输入数:");
int a=sc.nextInt();
if(a==num){
System.out.println("猜对了!");
break;
}
if(a<num){
System.out.println("猜小了,请继续:");
}
if (a>num){
System.out.println("猜大了,请继续:");
}
}
System.out.println("游戏结束");
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册