15,440
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<iomanip>
#include<ctime>
#include<cstdlib>
using namespace std;
const int N=20;
int main()
{
srand(time(NULL));
int i;
int a[N];
for(i=0;i<N;++i)
{
a[i]=rand()%100;
cout<<setw(5)<<a[i];
}
cout<<endl;
system("pause");
return 0;
}
#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() );
}