制作一个指定概率(例如10%)的抽奖系统。(用C语言写一个程序)
# include & ltstdio.h & gt
# include & ltstdlib.h & gt
void main()
{
int r,p;
char buf
Printf("请输入概率:(例如:概率10%,输入10)\ n ");
scanf("%d ",& ampp);
scanf("%c ",& ampbuf);
while(1)
{
r = rand()% 10 * 10/p;
如果(r==0)
{
Printf("恭喜你中了彩票!");
}
其他
{
Printf("不要赢!");
}
printf(" \ n ");
Printf("回车继续!\ n ");
scanf("%c ",& ampbuf);
如果(buf!='\n ')
打破;
}
}