package day4
;
import java
.util
.Scanner
;
public class dowhile1
{
public static void main(String
[] args
)
{
Scanner scan
= new Scanner(System
.in
);
int randNum
= (int)(Math
.random()*100);
int num
;
int flag
= 1;
do{
System
.out
.println("请输入你要猜的数:");
num
=scan
.nextInt();
if(num
< randNum
)
System
.out
.println("再大一点");
if(num
> randNum
)
System
.out
.println("再小一点");
if(num
== randNum
)
{
System
.out
.println("你猜对了");
break;
}
System
.out
.println("还想继续吗(1:继续 0:结束)");
flag
=scan
.nextInt();
}while(flag
== 1);
}
}
转载请注明原文地址:https://tech.qufami.com/read-5138.html