要一个随机整数,用C语言怎么编?
来源:百度知道 编辑:UC知道 时间:2024/05/13 13:22:52
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
void main( void )
{
int i;
srand( (unsigned)time( NULL ) );
for( i = 0; i 10;i++ )
printf( %6dn, random( 10 ) );
getchar();
}
a+rand()%b//比如说你要从0~100,那么a就取0,b就取100