Android易做图选号算法
public void loveyou() {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
int[] red2 = new int[5];
String a2 = "";
for (int i = 0; i < 5; i++) {
red2[i] = ((int) (Math.random() * 35 + 1));
// char b = (char) (Math.random() * 20 + 'a');
// a = a+" "+String.valueOf(b);
for (int j = i - 1; j > -1; j--)
{
if (red2[i] == red2[j])
{
i--;
break;
}
}
}
Arrays.sort(red2);
for (int i = 0; i < 5; i++)
{
a2 = a2 + " " + red2[i];
mTextView3.setText(a2);
}
int[] blue = new int[2];
String c = "";
for (int i = 0; i < 2; i++) {
red2[i] = ((int) (Math.random() * 12 + 1));
// char b = (char) (Math.random() * 20 + 'a');
// a = a+" "+String.valueOf(b);
for (int j = i - 1; j > -1; j--)
{
if (red2[i] == red2[j])
{
i--;
break;
}
}
}
Arrays.sort(red2);
for (int i = 0; i < 2; i++)
{
c = c + " " + red2[i];
mTextView4.setText(c);
}
int[] red1 = new int[6];
String a1 = "";
for (int i = 0; i < 6; i++) {
red1[i] = ((int) (Math.random() * 33 + 1));
// char b = (char) (Math.random() * 20 + 'a');
// a = a+" "+String.valueOf(b);
for (int j = i - 1; j > -1; j--)
{
if (red1[i] == red1[j])
{
i--;
break;
}
}
}
Arrays.sort(red1);
for (int i = 0; i < 6; i++)
{
a1 = a1 + " " + red1[i];
mTextView.setText(a1);
}
String blue2 = String.valueOf((int) (Math.random() * 16 + 1));
mTextView2.setText(blue2);
// TODO Auto-generated method stub
int[] red3 = new int[7];
String a3 = "";
for (int i = 0; i < 7; i++) {
red3[i] = ((int) (Math.random() * 9 + 0));
// char b = (char) (Math.random() * 20 + 'a');
// a = a+" "+String.valueOf(b);
}
Arrays.sort(red3);
for (int i = 0; i < 7; i++)
{
a3 = a3 + " " + red3[i];
mTextView5.setText(a3);
}
}
摘自 gongzibai的专栏
补充:移动开发 , Android ,