package test;
import java.util.Scanner;
public class SubLoop {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("10以内减法运算练习");
System.out.println("开始答题!");
int count = 0;
long startTime = System.currentTimeMillis();
Boolean flag=false;
do{
int number1 = (int)(Math.random()*10);
int number2 = (int)(Math.random()*10);
if(number1<number2){
int temp = number1;
number1 = number2;
number2 = temp;
}
System.out.println(number1+"-"+number2+"= ? ");
int answer = input.nextInt();
if(answer == (number1-number2)){
System.out.println("回答正确!");
count++;
}
else{
System.out.println("回答错误!");
System.out.println("正确答案是:"+(number1-number2));
}
System.out.print
利用循环实现Y/N多次选择
最新推荐文章于 2021-05-23 23:16:48 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)