Programming Assignment

I need help finishing a program.



#include <iostream>
#include <string>

using namespace std;

int main()
{
int unsorted[150];


for (int i = 0; i < 150; i++)

unsorted[i] = rand() % 150 + 1;

cout << "Here are the unsorted numbers: " << endl;

for (int i = 0; i < 150; i++)

cout << unsorted[i] << " ";

cout << "\n";

int sorted[150];


for (int i = 0; i < 150; i++)
{
int hi = -1;
int hiIndex = -1;
for (int j = 0; j < 150; j++)
{
if (unsorted[j] > hi)
{
hi = unsorted[j];
hiIndex = j;
}
}
sorted[i] = hi;
unsorted[hiIndex] = -1;
}

cin.ignore();

return 0;

}

This is what I have so far. Now I have to have it sorted and I must use \t escape sequence. I don't know where to start which is why I am looking for some help.
Last edited on
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.


http://www.cplusplus.com/reference/random/uniform_int_distribution/
What have you got so far? We can't help you unless you give us something to work with.
You'll need to know how to create loops and use rand() to generate random values. You'll also need if/and else statements to get the values within your range. Good luck.
Topic archived. No new replies allowed.