zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Java:循环输出随机数,直到输出88为止

JAVA循环输出 随机数 88 直到
2023-09-27 14:22:47 时间

代码:

public class BreakTest {
public static void main(String[] args) {
	int total = 0;
	System.out.println("Begin");
	while (true) {
		total++;
		int i = (int) Math.round(100 * Math.random());
		if (i == 88)
			break;
	}
	System.out.println("Game over, used " + total + " times.");
}
}