public
anonymous / gist:7903024
Created

  • Download Gist
gistfile1.txt
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#include <iostream>
#include <vector>
using namespace std;
//Function: Print_Array
void Print_Array(const vector<int>& Arr, int size){
cout << "Contents of the array" << endl;
for(int i = 0; i < size; i++){
cout << Arr[i] << " ";
}
cout << endl;
}
//Function: swap
void swap(int& a, int & b){
int temp=a;
a=b;
b=temp;
}
//Function: vector_sort
void vector_sort(vector<int>& Arr, vector<int> & vect){
int max_size=-1;
for(int j=0; j<Arr.size(); j++){
for(int i=0; i<Arr.size()-1; i++){
if(Arr[i+1]>Arr[i]){
swap(Arr[i+1],Arr[i]);
}
}
}
int num_size=-1;
for(int m=0; m<vect.size(); m++){
for(int n=0; n<vect.size()-1; n++){
if(vect[n+1]<vect[n]){
swap(vect[n+1], vect[n]);
}
}
}
}
 
 
int main(){
//First, we should declare the vectors to get them out of the way.
vector<int> start_time;
vector<int> end_time;
vector<int> schedule;
int num_act;
cout << "How many activities are there scheduled for today?";
cin >> num_act;
int start;
int end;
//to keep the while loop set, we need to keep count of how many enteries there are, or it will be infinite.
int act_entered=0;
while(act_entered<num_act){
cout << "Enter the start time:";
cin >> start;
start_time.push_back(start);
cout << "Enter the end time:";
cin >> end;
end_time.push_back(end);
act_entered++;
}
int cur_time=0;
for(int k=0; k<num_act; k++){
if(end_time[k]<=start_time[k+1]){
cur_time=end_time[k];
}
}
 
Print_Array(start_time, num_act);
vector_sort(start_time, end_time);
Print_Array(end_time, num_act);
return 0;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.