c 生成6个红球双色球号码

该C代码实现了一个函数pd,用于检查六位数组中是否存在重复元素。程序通过嵌套循环生成所有可能的六位数组合,并调用pd函数过滤出无重复数字的组合输出。
摘要由CSDN通过智能技术生成

从1-33 号球任选6个

现没有加入各种判断

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
    int h[]={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,33};
	int l[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
	
	int pd(int p[6]){
		int n=0;
		for(int a=0;a<6;a++){
			for(int b=a+1;b<6;b++){
				if(p[a]==p[b]){
					n=-1;
			
					goto aa;
				}
			}
		}
		n=1;
	aa:	return  n;
	}
	

	
	for(int a=0;a<33;a++){
		for(int b=0;b<33;b++){
			for(int c=0;c<33;c++){
				for(int d=0;d<33;d++){
					for(int e=0;e<33;e++){
						for(int f=0;f<33;f++){
							int z[]={a,b,c,d,e,f};
					
							if(pd(z)>0){
								printf("%d,%d,%d,%d,%d,%d    ;",h[a],h[b],h[c],h[d],h[e],h[f]);
							}
							
						}
					}
				}
			}
		}
	}
	

	return 0;

}

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值