#include <iostream>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;
const int FINISH = 2;
const int START = 5;
void getData(int arr[][FINISH]);
void displayData(int arr[][FINISH]);
bool insertionSort(const vector<int>& inner1, const vector<int>& inner2);
int i = 0;
int j = 0;
int main()
{
int timeArray[START][FINISH];
getData(timeArray);
displayData(timeArray);
vector<vector<int> > vect;
for (int i = 0; i < START - 1; ++i)
{
vector<int> inner(timeArray[i], timeArray[i] + 2);
vect.push_back(inner);
}
sort(vect.begin(), vect.end(), insertionSort);
for (int i = 0; i < START - 1; ++i)
{
timeArray[i][0] = vect[i][0];
timeArray[i][1] = vect[i][1];
}
displayData(timeArray);
cout << endl << endl << endl;
system("PAUSE");
return 0;
}
// used to prompt user to fill array with values
void getData(int arr[][FINISH])
{
cout << "Enter start/finish times." << endl
<< "One at a time when prompted: " << endl;
cout << endl;
for(int i = 0; i <= START - 1; i++)
{
cout << "Enter start time #" << i + 1 << ": ";
cin >> arr[i][j];
for(int j = 0; j <= 0; j++)
{
cout << "Enter finish time #" << i + 1 << ": ";
cin >> arr[i][j + 1];
}
cout << endl;
}
}// end getData()
// used to display array contents
void displayData(int arr[][FINISH])
{
cout << endl << endl;
for (int i = 0; i < START; i++)
{
for (int j = 0; j < FINISH; j++)
cout << arr[i][j] << " ";
cout << endl;
}
}// end displayData()
bool insertionSort(const vector<int>& inner1, const vector<int>& inner2)
{
return inner1[1] >= inner2[1];
}
I'm SO close...
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
topping2 challenge | 13 | 83 | |
detecting the added row index in a datagridview | 3 | 60 | |
Filename to be appended with DateTimeof Download | 3 | 46 | |
Compile error - linkage specification contradicts earlier specification for 'DllGetClassObject' | 6 | 23 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
19 Experts available now in Live!