7位数彩票 C语言

7位数彩票 C语言,第1张

不涉及**,就程序而言,

第1种情况是 可将7位数与10的取模然后保存在一个数组中,要比较三个数相等的,要3条if判断,12/13/23如相等则为真,有35个组合(123/124/125127/234/235/237/)就是说要将123三个数抽象为一个函数A,再调用35次

第2种各位的总和少于40大于10, 可将7位数与10的取模然后保存在一个数组中再求sum

第3种情况和第1种情况类似而且简单多了

第4种情况,在数组中设这奇数和偶数的标志i和j,当i和j=5时

第5和6种情况,同样在在数组中比较数字 是否大于或小于5的数,设的标志i和j,当i和j=5时

import javautilArrayList;

import javautilCollections;

import javautilList;

import javautilRandom;

public class Main {

public static void main(String[] args) {

//红球 33 选6

List<Integer> redBall = new ArrayList<Integer>();

for(int i=0;i<33;i++){

redBalladd(i+1);

}

Systemoutprintln("开奖红球:" + select(redBall, 6));

//篮球16选1

List<Integer> blueBall = new ArrayList<Integer>();  

for(int i=0;i<16;i++){

blueBalladd(i+1);

}

Systemoutprintln("开奖蓝球:" + select(blueBall, 1));

}

public static List<Integer> select(List<Integer> list,int count){

List<Integer> selectedList = new ArrayList<Integer>();

Random random = new Random();

for(int i=0;i<count;i++){

int index = randomnextInt(listsize());

Integer number = listget(index);

selectedListadd(number);

listremove(index);

}

    Collectionssort(selectedList);  

return selectedList;

}

}

以上就是关于7位数彩票 C语言全部的内容,包括:7位数彩票 C语言、Java 实现彩票程序、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/zz/10125277.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存