I have two questions out there for those who can respond.
1. How do I create a large array full of random integers?
2. How do I call the time so I can use it for checking the speed of a function?
I would appreciate any and all input.
meeloff
Printable View
I have two questions out there for those who can respond.
1. How do I create a large array full of random integers?
2. How do I call the time so I can use it for checking the speed of a function?
I would appreciate any and all input.
meeloff
1: Create a large array, use a loop and rand().
2. Make 2 time variables call time() on one in the begining of the function call the other at the end of the function call difftime on them and store that to a variable
for time read this http://www.cppreference.com/stddate_...s.html#asctime
Something like this:
I found this on MSDN.Code:#include <cstdlib>
#include <iostream>
void main()
{
int i;
int size = 50;
int array[size];
srand( (unsigned) time ( NULL ) );
for(i = 0; i < size; i++)
{
array[i] = rand();
}
}
Code:#include <cstdlib>
#include <ctime>
#include <iostream>
int main()
{
int i;
const int size = 50;
int array[size];
srand( (unsigned) time ( NULL ) );
for(i = 0; i < size; i++)
{
array[i] = rand();
}
}