C语言编写彩票程序

时间:2022-05-20 01:38:15 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
1 有重复数字的彩票程序



#include #include #include int main() {

intarr[7] = {},num = 0; srand(time(0));

for(num = 0;num <= 6;num++){ arr[num]=rand() % 36 + 1; }

for (num = 0; num<= 6;num++) { printf("%d ", arr[num]); }

printf("\n"); return 0; }

2 没有重复数字的彩票



#include #include #include int main() {

int lottery[7] = {}, num = 0, num1 = 0; srand(time(0)); do {

lottery[num] = rand() % 36 + 1;

for (num1 = 0;num1 <= num - 1;num1++) {

if (lottery[num1] == lottery[num]) { break; } }

if (!(num1 <= num - 1)) { num++; }

} while (num< 7);

for (num = 0;num <= 6;num++) {

printf("%d ", lottery[num]); }

printf("\n"); return 0; }




本文来源:https://www.wddqw.com/doc/3c7ff6b9d4d8d15abe234eb3.html