package DoubleBall;
import java.util.Arrays;
import java.util.Random;
public class DoubleBall {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] m_RedPool = { "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[] m_BluePool = { "01", "02", "03", "04", "05", "06", "07", "08",
"09", "10", "11", "12", "13", "14", "15", "16" };
Random tmpBall = new Random();
String[] m_Ball = {};
do {
int tmpOneBallNum = tmpBall.nextInt(32);
String tmpOneBall = m_RedPool[tmpOneBallNum];
// System.out.println(tmpOneBallNum);
if (m_Ball.length == 0) {
m_Ball = Arrays.copyOf(m_Ball, m_Ball.length + 1);
m_Ball[m_Ball.length - 1] = tmpOneBall;
}
for (int i = 0; i < m_Ball.length; i++) {
if (tmpOneBall == m_Ball[i]) {
break;
}
if(i==m_Ball.length-1){
m_Ball = Arrays.copyOf(m_Ball, m_Ball.length + 1);
m_Ball[m_Ball.length - 1] = tmpOneBall;
}
}
} while (m_Ball.length < 6);
System.out.println(m_Ball.length +" "+m_Ball[0] +" "+ m_Ball[1] +" "+ m_Ball[2] +" "+ m_Ball[3]
+" "+ m_Ball[4] +" "+ m_Ball[5]);
/*
* 排序红球
*/
String tmp;
for (int j = 0; j < m_Ball.length - 1; j++) {
char[] tmpball1 = new char[2];
tmpball1[0] = m_Ball[j].charAt(0);
tmpball1[1] = m_Ball[j].charAt(1);
for (int k = j + 1; k < m_Ball.length; k++) {
char[] tmpball2 = new char[2];
tmpball2[0] = m_Ball[k].charAt(0);
tmpball2[1] = m_Ball[k].charAt(1);
if (tmpball1[0] > tmpball2[0]) {
tmp = m_Ball[j];
m_Ball[j] = m_Ball[k];
m_Ball[k] = tmp;
} else if (tmpball1[0] == tmpball2[0]
&& tmpball1[1] > tmpball2[1]) {
tmp = m_Ball[j];
m_Ball[j] = m_Ball[k];
m_Ball[k] = tmp;
}
}
}
int tmpOneBallNum = tmpBall.nextInt(15);
m_Ball = Arrays.copyOf(m_Ball, m_Ball.length + 1);
m_Ball[m_Ball.length - 1] = m_BluePool[tmpOneBallNum];
System.out.println(m_Ball[0] + m_Ball[1] + m_Ball[2] + m_Ball[3]
+ m_Ball[4] + m_Ball[5] + m_Ball[6]);
}
}
双色球:字符串比较(day03-13.09.27)
最新推荐文章于 2022-12-14 23:56:39 发布