随机数函数rand和种子函数srand的使用

随机数函数rand和种子函数srand的使用

#include < stdlib.h >
#include
< stdio.h >
#include
< time.h >

int  main()
{
    
int i;
    time_t t;
    srand((unsigned)time(
&t));
    printf(
"ten random numbers from 0 to 99\n\n");
    
for(i = 0; i<10; i++)
    
{
        printf(
"%d\n",rand()%100);
    }

}

你可能感兴趣的:(随机数函数rand和种子函数srand的使用)