69,373
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
int magic;
srand(time(NULL));
magic=rand()%100-100;
//如何产生-100到100的随机数,C语言
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i;
int j;
srand((unsigned)time(NULL)); //产生不同的随机数
for(j=0;j<10;++j)
{
i = rand()%100;
if(i%2==0) //产生负数
i =-i;
printf("%d\n",i);
}
system("pause");
return 0;
}