I am needing help sorting the numbers that the random number generator puts out.
I have to create a vector, size 20. Display that vector. Sorts the vector and displays the resorted vector.
The other thing that my code has to do is creates a txt file of the output using command line redirection. But, i am not necessarily worried about this part yet.
#include <iostream>
#include <conio.h>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
usingnamespace std;
int main()
{
vector <int> vector;
int i = 0;
while (i++ < 20) //This is where you define how many numbers you want randomly generated
{
int r = (rand() % 100 + 0); //this is where you define what potential numbers you want generated.
// In this case, the numbers 0-100 are being used
cout << r << " ";
}
cout << "Press any key to quit.";
_getch();
return 0;
}//end main
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.