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
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
Last edited by prog-bman; 12-07-2004 at 03:57 PM.
Woop?
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(); } }
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens