189 8069 5689

抽签函数c语言 c语言抽奖

C语言怎么做个抽签程序,就是老师要用这程序来随即抽取学号来回答问题, 56个人,随即抽一人回答问题的代码

#includestdio.h

目前创新互联建站已为上1000+的企业提供了网站建设、域名、虚拟主机、网站托管维护、企业网站设计、鹤岗网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

#includestdlib.h

#includetime.h

void main()

{

int num;

time_t t;

srand((unsigned)time(t)); //获取当前时间作为种子,保证每次产生随机数的种子不同

num=random(60); //用函数random在0-60之间产生一个随机数

printf("num=%d",num);

}

希望回答对你有帮助!

【原创答人】

制作一个指定概率(例如10%)的抽签系统.(使用C语言编写程序)

#include stdio.h

#include stdlib.h

void main()

{

int r,p;

char buf;

printf("请输入概率:(举例:概率10%,输10)\n");

scanf("%d",p);

scanf("%c",buf);

while(1)

{

r=rand()%10*10/p;

if(r==0)

{

printf("恭喜中奖!");

}

else

{

printf("不中奖!");

}

printf("\n");

printf("按回车键继续!\n");

scanf("%c",buf);

if(buf!='\n')

break;

}

}

怎样用C语言制作姓名抽签器上课抽签用

用随机数抽出号数,可以用switch case将号数的主人打印出来

#include stdio.h

#include time.h

#include stdlib.h

int main()

{

int a = 0;

srand((unsigned)time(NULL));

a = rand()%40 + 1; /*1到40号中抽出一个*/

printf("%d\n",a);

return 0;

}


当前文章:抽签函数c语言 c语言抽奖
浏览地址:http://cdxtjz.cn/article/doicsgd.html

其他资讯