-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP25_4_classroom_scheduling.cpp
144 lines (125 loc) · 3.65 KB
/
P25_4_classroom_scheduling.cpp
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// #include<iostream>
// #include<bits/stdc++.h>
// using namespace std;
// void sorting(double arr[], int l){
// for(int i=0;i<l-1;i++){
// for(int j=0;j<l-i-1;j++){
// if(arr[j]>arr[j+1]){
// double temp=arr[j];
// arr[j]=arr[j+1];
// arr[j+1]=temp;
// }
// }
// }
// }
// int main(){
// int no_of_classes;
// cout<<"Enter the no. of classes today:"<<endl;
// cin>>no_of_classes;
// int len=2*no_of_classes;
// int arr_start[len],arr_end[len];
// cout<<"Enter the start times of every of every class in 24hr format:"<<endl;
// for(int i=0;i<len;i++){
// cout<<"Enter hours of class"<<i+1<<endl;
// cin>>arr_start[i];
// // cout<<":";
// i++;
// cout<<"Enter minutes of class"<<i<<endl;
// cin>>arr_start[i];
// }
// cout<<endl;
// cout<<"Enter the end times of every of every class in 24hr format:"<<endl;
// for(int i=0;i<len;i++){
// cout<<"Enter hours of class"<<i+1<<endl;
// cin>>arr_end[i];
// // cout<<":";
// i++;
// cout<<"Enter minutes of class"<<i<<endl;
// cin>>arr_end[i];
// }
// cout<<"Start times of every of every class in 24hr format:"<<endl;
// for(int i=0;i<len;i++){
// cout<<arr_start[i];
// cout<<":";
// i++;
// cout<<arr_start[i];
// cout<<" ";
// }
// cout<<endl;
// cout<<"End times of every of every class in 24hr format:"<<endl;
// for(int i=0;i<len;i++){
// cout<<arr_end[i];
// cout<<":";
// i++;
// cout<<arr_end[i];
// cout<<" ";
// }
// int l=len/2;
// double start_time[l],end_time[l];
// for(int i=0;i<l;i++){
// start_time[i]=arr_start[i]+((arr_start[i+1]/60));
// }
// for(int i=0;i<l;i++){
// end_time[i]=arr_end[i]+((arr_end[i+1]/60));
// }
// //continued!!!!!
// sorting(start_time,l);
// sorting(end_time,l);
// return 0;
// }
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cout<<("Enter the number of classes")<<endl;
cin>>n;
int st_time[n];
int end_time[n];
string clas[n];
cout<<("Enter the name of the classes")<<endl;
for(int i=0;i<n;i++)
{
cin>>clas[i];
}
cout<<("Enter the start and end timings of the classes")<<endl;
for(int i=0;i<n;i++)
{
cin>>st_time[i];
cin>>end_time[i];
}
string order="";
for(int i=0;i<n;i++)
{
for(int j=0;j<n-i-1;j++)
{
if(end_time[j]>end_time[j+1])
{
int temp1=end_time[j];
end_time[j]=end_time[j+1];
end_time[j+1]=temp1;
temp1=st_time[j];
st_time[j]=st_time[j+1];
st_time[j+1]=temp1;
string temp2=clas[j];
clas[j]=clas[j+1];
clas[j+1]=temp2;
}
}
}
order=order+clas[0]+" ";
int temp=0;
for(int i=1;i<n;i++)
{
if(end_time[temp]<=st_time[i])
{
order=order+clas[i]+" ";
temp=i;
}
else
{
continue;
}
}
cout<<"The order of classes = "+order<<endl;
}