Hi, I am trying to put random numbers in array, and use the array for other functions. However, I am stuck on inputting and displaying that array with random numbers. Can someone help? Please ignore other cases, and focus on case 0, which is displaying the elements of the array.
I have included header and cpp file.
Header file:
//Header File for Sorting.cpp
#include <iostream>
#include <fstream>
#include <time.h>
#include <ctime>
#include <cstdlib>
using namespace std;
class Sort{
clock_t start,finish; // Clock
public:
// (0) View unsorted list
void display(int array) {
cout << array << endl;
}
}
CPP File:
#include "Sorting.h"
int main () {
cout << "Main Start" << endl;
//double produce(int *array) {
// 1st Argument
int array[1000],n,N,input;
cout << "Input total # of numbers to be sorted: ";
// Output Unsorted Numbers
ofstream myfile;
myfile.open ("input-N.txt");
srand((unsigned)time(0));
cin >> N; // Input # of numbers to be sorted
for(int i=0; i<N; i++) {
array[i] = (rand()%10000)+1; // Random number of 100 <= N <= 10,000
myfile << array[i] << endl;
}
return *array;
myfile.close();
// 2nd Argument
{
cout << "\n\nPick a Computing Mode:\n";
cout << "0. View Unsorted array\n";
cout << "1. Exit\n";
cout << "\nSelection: ";
cin >> input;
switch (input) {
Sort Sorting;
case 0:
Sorting.display(array);
cout << "Displaying Unsorted array\n";
break;
case 1:
cout << "Exiting.............";
break;
default: cout << "\nInvalid Choice";
break;
}
cin.get();
}
}