首页 > 其他 > 详细

彩票随机数

时间:2016-04-17 23:24:59      阅读:248      评论:0      收藏:0      [点我收藏+]

[root@svr7 bin]# cat lottery.c 

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

int main() {

    int lottery[7]={},num = 0;

    srand(time(0));

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

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

}

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

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

}

    printf("\n");

return 0;

}

[root@svr7 bin]# gcc lottery.c 

[root@svr7 bin]# ./a.out 

27 33 32 23 23 23 13 


本文出自 “Linux运维之道” 博客,谢绝转载!

彩票随机数

原文:http://sigelinux.blog.51cto.com/8875874/1764805

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!