「猜彩票JAVA」竞彩网 中国体育竞猜彩票

博主:adminadmin 2022-11-28 14:47:08 61

本篇文章给大家谈谈猜彩票JAVA,以及竞彩网 中国体育竞猜彩票对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

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

}

}

用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编程 输入一个七位数,计算机产生一组彩票号码 判断是否中奖

Math 类包含用于执行基本数学运算的方法,如初等指数、对数、平方根和三角函数。

random() //返回带值大于等于 0.0到

1.0的小数。

提示:调用math.random()方法,一次生成七位数。判断输入的数是否相等。

JAVA猜数字游戏:现在规则如下,输入一个1-100之间的数请人猜

等下我在给你写

public static void main(String[] args) {

       

        Scanner scanner = new Scanner(System.in);

        System.out.println("输入初始数字:");

        int input = scanner.nextInt();

        int count = 0;  //计数

        System.out.println("猜一个数字:");

        for(;;){

            int cai = scanner.nextInt();

            count++;

            if(cai==input){

                System.out.println("恭喜你,猜对了,赶紧去买彩票吧!");

                break;

            }else{

                if(caiinput){

                    System.out.println("太小了,继续猜。。。");

                }else{

                    System.out.println("太大了,继续猜。。。");

                }

            }

        }

    }

java如何编程福利彩票30选7,我自己编的但是不知道有什么错误,希望帮我纠正一下,标注一下我的错误

你这个逻辑很混乱啊,数组a没有初始化,i也不是全局变量。全局变量和局部变量用的很乱。这个程序不能用

public static void main(String[] args){

Random r=new Random();

for(i=0;i7;i++){//i没有初始化

a[i]=1+r.nextInt(30);//a[]没有初始化

while(true)

{

panDuan(a[i]);

if(i==j) break;//j不是全局变量,这里不能用

}

}

Arrays.sort(a);//这里排序干啥?七彩乐规则我不太懂

for(int k=0;k7;k++){

System.out.print(a[k]+" ");}

}

private static void panDuan(int b) {

for(int j = 0;ji;j++)

if(a[j]==b) break;//a[]不是全局变量,这里不能调用

// TODO Auto-generated method stub

}

}

你说下具体规则,我把程序写好给你吧

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的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于竞彩网 中国体育竞猜彩票、猜彩票JAVA的信息别忘了在本站进行查找喔。

The End

发布于:2022-11-28,除非注明,否则均为首码项目网原创文章,转载请注明出处。