随机数生成程序!!!
下面是一个随机数生成程序,如何使得随机数生成在1-100的范围之内啊?谢谢!#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/timeb.h>
void main(void)
{
int i;
unsigned int seedVal;
struct timeb timeBuf;
ftime(&timeBuf);
seedVal=((((unsigned int)timeBuf.time&0xFFFF)+
(unsigned int)timeBuf.millitm)^
(unsigned int)timeBuf.millitm);
srand((unsigned int)seedVal);
for(i=0;i<10;++i)
printf("%6d\n",rand());
}