五谷杂粮豆浆怎么打:rand()是哪个文件力的函数啊

来源:百度文库 编辑:高校问答 时间:2024/04/29 20:51:47
是在#include <stdoi.h>的吗?
它的用法是怎们样啊

是stdlib.h的

randomize();//初始化随机数
int k=rand()%n;//在n之间的数

math.h 么?

/* RAND.C: This program seeds the random-number generator
* with the time, then displays 10 random integers.
*/

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

void main( void )
{
int i;

/* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) );

/* Display 10 numbers. */
for( i = 0; i < 10;i++ )
printf( " %6d\n", rand() );
}

<stdlib.h>中的
/********
_CRTIMP ldiv_t __cdecl ldiv(long, long);
_CRTIMP char * __cdecl _ltoa(long, char *, int);
_CRTIMP void * __cdecl malloc(size_t);
_CRTIMP int __cdecl mblen(const char *, size_t);
_CRTIMP size_t __cdecl _mbstrlen(const char *s);
_CRTIMP int __cdecl mbtowc(wchar_t *, const char *, size_t);
_CRTIMP size_t __cdecl mbstowcs(wchar_t *, const char *, size_t);
_CRTIMP void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)
(const void *, const void *));
_CRTIMP int __cdecl rand(void);
_CRTIMP void * __cdecl realloc(void *, size_t);
_CRTIMP int __cdecl _set_error_mode(int);
_CRTIMP void __cdecl srand(unsigned int);
_CRTIMP double __cdecl strtod(const char *, char **);
_CRTIMP long __cdecl strtol(const char *, char **, int);
**************************/