用c语言编写体育彩票10选7(7个号码可以重复)的程序,哪位帮帮忙?

来源:百度知道 编辑:UC知道 时间:2024/05/30 09:47:03

在vc下是用不了的;
好像vc没有random函数。
#include "stdlib.h" /*调用随机函数*/
main()
{
int i,n,j;
clrscr();/*清屏*/
printf("please input the groups: \n");
scanf("%d",&n);
j=n+1;
while(n)
{
randomize(); /*初始化随机数产生器*/
printf("the %3d groups: ",j-n);
for(i=1;i<8;i++)
printf("%d ",random(10)); /*产生0到(10-1)之间的随机数*/
printf("\n");
n--;
getch();
}
}

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int i;
srand(time(0));

for (i=0;i<7;i++) printf("%d\t",rand()%11);

putchar('\n');

system("pause");
return 0;
}

最简单的就是随即函数