Android lottery Selection Algorithm

Source: Internet
Author: User

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 );

}

}

 

 


From the column of gongzibai

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.