用
#include<stdlib.h>
#include<stdio.h>
void main()
{ int i;
randomize();
for(i=0;i<=100;i++)
{printf("%d\n",rand()%17+1);
}
}
这是1到17的随机数
randomize();用系统函数做种子
数名: random
功 能: 随机数发生器
用 法: int random(int num);
程序例:
#include
#include
#include
/* prints a random number in the range 0 to 99 */
int main(void)
{
randomize();
printf("Random number in the 0-99 range: %d\n", random (100));
return 0;
}