Need some help with HW(Arrays)

Apr 28, 2014 at 12:39am
I need some help with this array for a HW assignment, we have to generate random numbers using an array then ask the user to quit, reorder the same numbers randomly, reorder them in ascending order or recreate the numbers.
At this point in my code thats all I need help with is the final few lines of my code, please help!

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
36
37
38
39
40
41
42
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string choice;
    do{
    int size;
        cout<< "How many numbers?" << endl;
        cin >> size;



    int array[size];

        srand((unsigned)time(0));

        cout<< "Numbers created: " << endl;

        for(int i=0; i<size; i++){
            array[i] = (rand()%100)+1;
            cout << array[i] << endl;
        }

        cout << "Select an option: " << endl;
        cout << "0 To quit" << endl;
        cout << "1 to re-order numbers randomly" << endl;
        cout << "2 to re-order numbers in ascending order" << endl;
        cout << "3 to recreate the numbers" << endl;
        cin >> choice;

        if (choice == "0");
        else if(choice == "1")
            cout << array << endl;

        }while(choice == "0,1,2,3");
 }
Topic archived. No new replies allowed.