在VC++ 6.0中,怎么产生1-9的随机数?
參考答案:#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
int main(void)
{
srand(time(NULL));
int t = rand() % 8 + 1;
printf("你要的随机数是 %d \n",t);
return 0;
}
在VC++ 6.0中,怎么产生1-9的随机数?
參考答案:#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
int main(void)
{
srand(time(NULL));
int t = rand() % 8 + 1;
printf("你要的随机数是 %d \n",t);
return 0;
}