考试题
来源:互联网 发布:北京seo实战培训 编辑:程序博客网 时间:2024/04/29 11:04
package com.UUU.util;
public class KaoShi {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
System.out.print(random9() + " ");
}
}
/**
* 根据random8,生成[1,9]之间的随机数
*
* @return
*/
private static int random9() {
int x;
do {
x = random8() * 8 + random8();
} while (x == 8 * 8 - 1);
return x % 9 + 1;
}
/**
* 生成[1,8]之间的随机数
*
* @return
*/
private static int random8() {
int r = (int) (Math.random() * 8) + 1;
return r;
}
}
public class KaoShi {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
System.out.print(random9() + " ");
}
}
/**
* 根据random8,生成[1,9]之间的随机数
*
* @return
*/
private static int random9() {
int x;
do {
x = random8() * 8 + random8();
} while (x == 8 * 8 - 1);
return x % 9 + 1;
}
/**
* 生成[1,8]之间的随机数
*
* @return
*/
private static int random8() {
int r = (int) (Math.random() * 8) + 1;
return r;
}
}
0 0
- 考试题
- 考试题
- 考试题
- 考试题
- C#考试题
- javaweb考试题
- c++考试题
- .net考试题
- .net考试题
- OOA考试题
- JAVA考试题
- 考试题记录
- C++考试题
- 考试题改错
- ado考试题
- java考试题
- 期末考试题
- 考试题改错
- UML视频总结
- 实现任意图片垂直居中的三种方法
- Jquery 简单切换事件
- 实验matching_to_many_images
- 4岁男童拿剪刀当玩具 不慎摔跤戳入脖子险丧命(图)
- 考试题
- adb offline & adb authorized
- Canvas实例教程:图像移动、大小调整和裁剪
- BNU 34986 Football on Table
- Unity 核心类
- Jieba分词包(一)——解析主函数cut
- 水晶报表无法编辑公式字段
- Mybatis中的like查询
- 用消息队列和消息应用状态表来消除分布式事务