|  | 
 
| 
本帖最后由 18227452746 于 2022-2-26 15:29 编辑
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  
 #include<stdio.h>
 #include<stdlib.h>
 #include<time.h>
 #include<windows.h>
 int main()
 {
 srand(time(NULL));
 int hq1,hq2,hq3,hq4,hq5,hq6;
 int lq;
 int i;
 for(i=0;i<10;i++)
 {
 MAA:
 hq1 = rand()%33+1;
 hq2 = rand()%33+1;
 hq3 = rand()%33+1;
 hq4 = rand()%33+1;
 hq5 = rand()%33+1;
 hq6 = rand()%33+1;
 lq = rand()%16+1;
 
 if(hq1==hq2 || hq1==hq3 || hq1==hq4 || hq1==hq5 || hq1==hq6 || hq2==hq3 || hq2==hq4 || hq2==hq5 || hq2==hq6 || hq3==hq4 || hq3==hq5 || hq3==hq6 || hq4==hq5 || hq4==hq6 || hq5==hq6 )
 {
 goto MAA;
 }
 else{
 printf("******************************************************************************\n");
 printf("第%d组号码:\n",i+1);
 printf("红球号码为:\t%d\t%d\t%d\t%d\t%d\t%d\n篮球号码为:\t%d\n",hq1,hq2,hq3,hq4,hq5,hq6,lq);
 printf("******************************************************************************\n");
 Sleep(500);
 }
 }
 getchar();
 return 0;
 }
 
 
复制代码#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 6
void r(int *blue){
    for(int i = 0; i < N; i++) blue[i] = rand() %33 + 1;
}
int check(int *blue){
    for(int i = 0; i < N-1; i++)
    for(int j = i+1; j < N; j++)
    if(blue[i] == blue[j])
    return 0;
    return 1;
}
int main()
{
    srand(time(NULL));
    int blue[6], red = rand() %16 + 1;
    while(1){
        r(blue);
        if(check(blue)) break;
    }
    printf("blue balls: ");
    for(int i = 0; i < N; i++) printf("%d ", blue[i]);
    printf("\nred  balls: %d\n", red);
    return 0;
}
复制代码blue balls: 15 10 28 21 4 19 
red  balls: 1
 | 
 |