2007年5月13日星期日

我要开始买彩票啦。


/**
* Created by IntelliJ IDEA.
* User: Henry Zhu
* Date: 2007-5-14
* Time: 9:28:40
* To change this template use File | Settings | File Templates.
*/
import java.util.*;


public class random {
public static void main(String[] args)
{int[] num={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32};
Random r=new Random();
//StringBuffer str1=new StringBuffer();
int com=0;
System.out.println("The common six number are:");
for(int i = 0; i < 6; i ++) {
com = r.nextInt(32 - i);
System.out.println(num[com]);
for(int j = com; j < 32 - i - 1; j ++) {
num[j] = num[j + 1];
}
}
int[] num2={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
Random r2=new Random();
int spe=0;
spe=r2.nextInt(16);
System.out.println("The special number is: " + num2[spe]);
}
}


KsharP


2007-05-14


Henry Zhu


QQ:284841013


MSN:ksharp1229@hotmail.com


Email:zhuheng1229@gmail.com


Homepage:http://ksharp.anyp.cn




1 条评论:

匿名 说...

修改了一下,程序改成这样比较好。
/**
* Created by IntelliJ IDEA.
* User: Henry Zhu
* Date: 2007-5-14
* Time: 9:28:40
* To change this template use File | Settings | File Templates.
*/
import java.util.*;
import java.lang.*;

public class random
{
public static void main(String[] args)
{int[] num={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32};
Random r=new Random();
//StringBuffer str1=new StringBuffer();
int com=0;
System.out.println("The common six number are:");
int[] out={1,2,3,4,5,6};
for(int i = 0; i < 6; i ++)
{
com = r.nextInt(32 - i);
// System.out.println(com);
System.out.println("the number "+(i+1)+" is "+num[com]);
out[i]=num[com];
for(int j = com; j < 32 - i - 1; j ++)
{
num[j] = num[j + 1];
}

// System.out.println("array out["+i+"] is "+out[i] );
}

int[] num2={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};

Random r2=new Random();
int spe=0;
spe=r2.nextInt(16);
for (int m=0; m<6;m++)
{
// System.out.println("array out["+m+"] is "+out[m] );
if (spe==out[m])
{System.out.println("Please run again and ignore the below special number");}
}
System.out.println("The special number is: " + spe);
}
}