「彩票招java」彩票招聘2022
本篇文章给大家谈谈彩票招java,以及彩票招聘2022对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、java实现彩票窗口,设计和实现35选7的彩票程序,以GUI界面提供如下功能
- 2、用Java程序写一个彩票的模拟程序生成6个红球(1-33的随机数),1个蓝球(1-16的随机数),随机数可以重复
- 3、java的彩票
- 4、用JAVA编写一个福利彩票机选模拟器,使用随机数方法
- 5、3D彩票JAVA编程怎么写?
- 6、Java 编写一个双色球彩票系统,用户从键盘输入6个1-33的数字,与系统自动产生的1-33
java实现彩票窗口,设计和实现35选7的彩票程序,以GUI界面提供如下功能
可选中1个或多个下面的关键词,搜索相关资料。也可直接点“搜索资料”搜索整个问题。
35选7
java
gui
用Java程序写一个彩票的模拟程序生成6个红球(1-33的随机数),1个蓝球(1-16的随机数),随机数可以重复
import java.util.Random;
import java.util.Scanner;
public class DoubleBalls {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("是否机选一组双色球号码?(Y/N)");
Scanner input = new Scanner(System.in);
char a = input.next().charAt(0); // 输入一个char字符,0位即是第一位
if (a == 'Y' || a == 'y') {
Random suiji = new Random(); // 创建suiji方法
int blue = suiji.nextInt(16);//从0到16中选一个数字个蓝球
while(blue==0){
blue=suiji.nextInt(16);
}//如果选到了0,再选一次给blue
int red[] = new int[6];// 用一个6个元素的数组装红球
for (int i = 0; i 6; i++) {
red[i] = suiji.nextInt(33); // 随机分配0到33的整数
if (red[i] == 0) {i--;}
if (i == -1) {i = 0;}
for (int j = 0; j i; j++) {
while (red[i] == red[j]) {i--;}// 发现相同的从新回去生成一个
}
}
System.out.print("红球:");
for (int k = 0; k red.length; k++) {
System.out.print(red[k] + " ");// 输出数组red
}
System.out.print("蓝球:"+blue);
} else
System.out.println("fuck you~");
}
}
应该可以了,可以产生一组。。。如果楼主你中头奖了,送我套房好了哈^0^
java的彩票
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
/**
* 测试彩票类
* @author doulmi
*
*/
public class LotteryDemo {
public static void main( String[] args ) {
Scanner scanner = new Scanner( System.in );
System.out.print( "请输入要购买的注数:" );
System.out.println();
int buyN = 0;
if ( scanner.hasNextInt() ) {
buyN = scanner.nextInt();
} else {
System.out.println( "请输入正确的数字" );
}
for ( int i = 0; i buyN; i ++ ) {
Lottery lot = new Lottery();
lot.generate();
System.out.print( "第" );
System.out.print( i );
System.out.print( "注" );
lot.printData();
}
}
}
/**
* 彩票类
* @author Administrator
*
*/
class Lottery {
private static final int NUM_TO_GETOUT = 7;
//能产生的最大数值为99
private static final int MAX_NUM = 35;
public ArrayList Integer list;
private int[] result;
public Lottery() {
list = new ArrayList Integer ();
for ( int i = 1; i = MAX_NUM; i ++ ) {
list.add( i );
}
result = new int[ NUM_TO_GETOUT ];
}
public void generate() {
Random r = new Random();
for ( int i = 0; i NUM_TO_GETOUT; i ++ ) {
result[ i ] = list.remove( r.nextInt( list.size() ) );
}
}
/**
* 关于票头的打印。。我不知道票头是什么。
*/
public void pringTitle() {
}
/**
* 实现号码的打印
*/
public void printData() {
for ( int n : result ) {
System.out.print( n );
System.out.print( " " );
}
System.out.println();
}
}
用JAVA编写一个福利彩票机选模拟器,使用随机数方法
自己写的,不懂可以问我
import java.util.Random;
import java.awt.*;
import java.awt.event.*;
public class shuangSeQiu implements ActionListener{
int i,k;
static int rm,rr;
int [] a = new int [33];
Frame f = new Frame("双色球随机数");
TextField tf = new TextField();
Random rd = new Random();
public shuangSeQiu()
{
for(i=0;i33;i++)
{
a[i] = i;
}
f.setLayout(new BorderLayout());
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void init()
{
tf.addActionListener(this);
Button b = new Button("开始");
b.addActionListener(this);
f.add(tf,"North");
f.add(b);
f.setSize(300,300);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("开始"))
//tf.setText(""+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" 蓝色球号码:"+(rd.nextInt(15)+1));
{
/*rr = new Random().nextInt(33);
rm = new Random().nextInt(33);*/
for(i=0;i33;i++)
{
rr = new Random().nextInt(33);
rm = new Random().nextInt(33);
System.out.print(rr+" ");
k=a[rm];
a[rm]=a[rr];
a[rr]=k;
}
tf.setText("红色球号码:"+(a[0]+1)+" "+(a[1]+1)+" "+(a[2]+1)+" "+(a[3]+1)+" "+(a[4]+1)+" "+(a[5]+1)+" 蓝色球号码:"+(rd.nextInt(15)+1));
}
}
public static void main(String[] args)//throws Exception
{
new shuangSeQiu().init();
}
}
3D彩票JAVA编程怎么写?
import java.util.ArrayList;import java.util.List;import java.util.Random;import java.util.Scanner; public class Lotto { public static final int NUMBER = 7; public static void main(String[] args) { ListInteger userNumbers = new ArrayListInteger(); Scanner scanner = new Scanner(System.in); int i = 1; while(i 8) { System.out.println("输入第" + i + "个数字: "); userNumbers.add(scanner.nextInt()); i ++; } System.out.println(prize(userNumbers.toArray(new Integer[NUMBER]))); } private static Integer[] generateLotto() { ListInteger lottoNumbers = new ArrayListInteger(); Random rand = new Random(); int lottoNumber, i = 0; while(i NUMBER) { lottoNumber = rand.nextInt(35) + 1; if(!lottoNumbers.contains(lottoNumber)) { lottoNumbers.add(lottoNumber); i ++; } } return bubbleSort(lottoNumbers.toArray(new Integer[NUMBER])); } private static Integer[] bubbleSort(Integer[] array) { for(int i = 0; i array.length; i ++) { for(int j = 0; j array.length - i - 1; j ++) { if(array[j] array[j + 1]) { int temp = array[j + 1]; array[j + 1] = array[j]; array[j] = temp; } } } return array; } public static String prize(Integer[] userNumbers) { int count = 0; Integer[] lottoNumbers = generateLotto(); for(Integer i : userNumbers) { for(Integer j : lottoNumbers) { if (i == j) { count ++; } } } return "猜对了 "+ count + " 个彩票号码"; }}
输入第1个数字:
5
输入第2个数字:
14
输入第3个数字:
19
输入第4个数字:
24
输入第5个数字:
33
输入第6个数字:
34
输入第7个数字:
27
猜对了 3 个彩票号码
Java 编写一个双色球彩票系统,用户从键盘输入6个1-33的数字,与系统自动产生的1-33
就不写代码了,别人写的代码复制也没意思,给你个思路。
首先获取1到33的随机数,然后放入一个listbyte集合中。每次放入集合都要判断该集合中是否存在这个数字,如果存在则重新获取随机数。如果集合长度为6,则停止获取随机数,这个集合里就是本次嗯中奖号码。然后就是让用户输入6个数字,同样放到一个集合中,放入至少检验用户输入的是否是1-33的数字,并且这个集合里面是否有这个数字。如果有,要用户重新输入。等用户输入完,再循环0-5的下标,分别从两个集合中取值,对比,设置一个byte变量,如果值相同,则产量加1。最后判断这个产量的值为几,就知道有几个相同的了,然后根据相同的个数来打印出用户获得了几等奖。如果你还没学集合,那就用byte数组。
彩票招java的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于彩票招聘2022、彩票招java的信息别忘了在本站进行查找喔。