-
Notifications
You must be signed in to change notification settings - Fork 0
/
array_generator.cpp
35 lines (28 loc) · 1.32 KB
/
array_generator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//************************************************************************************
// File: arraygenerator.cpp
// Author: Amauri Tuoni
//
// Program to generated a array of random integer numbers. Interval from 0 to 10.
//
// Created on 26 de Setembro de 2020, 17:40
//************************************************************************************
#include <iostream> //prototype for the cout function
#include <cstdlib>
#include <ctime> //prototype for the function time
#include "array_generator.h" //header of this function
//#define RAND_MAX 10
using namespace std;
void array_generator(int *data,int size)
{
int number; //variable to store the number
unsigned int seed; //variable to store the seed
seed = time(0); //generate the seed using the actual time
srand(seed); //put the seed on the random number generator
for(int element=0;element<size;element++) //run each element of the data array
{
number = rand()%10; //generate random number in the 0-10 interval
data[element]=number; // put the number on the data array
cout<<"Generating array with "<<element+1<<" elements ..."<< endl; //print on the screen a message for each element generated
}
cout<<"Done."<<endl<<endl; // print on the screen that the array generation was done.
}