我想得到100个10000至99999的正随机数
可是会有些负的……为什么?
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<time.h>
int main()
{
int a,i;
srand( (unsigned)time( NULL ) );
for(i=0;i<100;i++)
{
a=rand()%99999+10000;
printf("%d\n",a);
}
getch();
return 0;
}
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<time.h>
int main()
{
long a;
int i;
srand( (unsigned)time( NULL ) );
for(i=0;i<100;i++)
{
a=rand()%89999+10000;
printf("%d\n",a);
}
getch();
return 0;
}
改成这样貌似还不行