Android 双色球机选算法
来源:互联网 发布:最强淘宝系统笔趣阁 编辑:程序博客网 时间:2024/06/04 18:06
/*
* 双色球机选算法
*
*/
public void doClick(View view) {
TextView tv1 = (TextView) findViewById(R.id.textView1);
TextView tv2 = (TextView) findViewById(R.id.textView2);
String[] red = {
"01","02","03","04","05","06","07","08","09","10",
"11","12","13","14","15","16","17","18","19","20",
"21","22","23","24","25","26","27","28","29","30",
"31","32","33"
};
String[] blue = {
"01","02","03","04","05","06","07","08","09","10",
"11","12","13","14","15","16"
};
boolean[] flags = new boolean[red.length];
String[] redResult = new String[6];
// 选红球
for(int i=0;i<redResult.length;i++) {
int index;
do {
index = new Random().nextInt(red.length);
} while(flags[index]);
flags[index] = true;
redResult[i] = red[index];
}
// 选蓝球
String blueResult = blue[new Random().nextInt(blue.length)];
// 显示
tv1.setText(Arrays.toString(redResult));
tv2.setText(blueResult);
}
* 双色球机选算法
*
*/
public void doClick(View view) {
TextView tv1 = (TextView) findViewById(R.id.textView1);
TextView tv2 = (TextView) findViewById(R.id.textView2);
String[] red = {
"01","02","03","04","05","06","07","08","09","10",
"11","12","13","14","15","16","17","18","19","20",
"21","22","23","24","25","26","27","28","29","30",
"31","32","33"
};
String[] blue = {
"01","02","03","04","05","06","07","08","09","10",
"11","12","13","14","15","16"
};
boolean[] flags = new boolean[red.length];
String[] redResult = new String[6];
// 选红球
for(int i=0;i<redResult.length;i++) {
int index;
do {
index = new Random().nextInt(red.length);
} while(flags[index]);
flags[index] = true;
redResult[i] = red[index];
}
// 选蓝球
String blueResult = blue[new Random().nextInt(blue.length)];
// 显示
tv1.setText(Arrays.toString(redResult));
tv2.setText(blueResult);
}
0 0
- Android 双色球机选算法
- Android 算法
- Android 倒影实现算法
- android 日历 农历算法
- Android 彩票选号算法
- android 图片 倒影 算法
- Android二值化算法
- android 缓存算法介绍
- Android AES算法示例
- Android资源匹配算法
- Android图片二值化算法
- Android 农历日历算法
- android进程回收算法
- Android 图像算法处理
- android Rsa 算法加密
- 日历算法Android
- android 常用的算法
- Android图片压缩算法
- oracle中去掉某列重复的记录
- 不通过表单访问带有命名空间的action
- IIS配置遇到的问题—— 处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHan
- 双缓冲消息队列-减少锁竞争
- 多线程
- Android 双色球机选算法
- 正则表达式30分钟入门教程
- 第六周作业——哈夫曼编码
- redis的源码分析之不同编码类型的数据结构
- 最快线程间数据交换算法,有效避免锁竞争 -- TwoQueues
- mysql partition 分区功能详细介绍,以及实例
- mongoose源码分析系列一
- Android 开发技术汇总
- codeforces 420B Online Meeting