Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct hour{
- int h, m;
- hour(){
- h = 0; // часы
- m = 0; // минуты
- }
- };
- int main(int argc, char **argv){
- if (argc < 1) {
- cout << "Error: not enpugh input arguments" << endl;
- return 1;
- }
- ifstream in;
- in.open(argv[1]); // открывает файл с координатами и количеством точек
- if (!in.is_open()) // в случае, если файл не открылся
- {
- cout << "Error: can't open the file" << endl;
- return 1;
- }
- int minuta1=0, minuta2 = 0;
- cout << "Vvedite vremya itkriya i zakr";
- int h1, m1, h2, m2;
- cin >> h1 >> m1 >> h2 >> m2;
- minuta1 = h1 * 60 + m1;
- minuta2 = h2 * 60 + m2;
- int minutes[600]; // обнуляем массив всех минут
- for (int i = 0; i < 599; i++)
- minutes[i] = 0;
- int n;
- in >> n;
- hour *time1 = new hour[n];
- int *min1 = new int[n];
- hour *time2 = new hour[n];
- int *min2 = new int[n];
- for (int j = 0; j < n; j++) {
- in >> time1[j].h >> time1[j].m;
- min1[j] = time1[j].h * 60 + time1[j].m; // минута входа
- in >> time2[j].h >> time2[j].m;
- min2[j] = time2[j].h * 60 + time2[j].m; // минута выхода
- }
- //for (int j = 0; j < n; j++)
- //cout << min1[j] << " " << min2[j] << endl;
- int count = 0;
- int max = 0;
- int imax = 0;
- for (int i = minuta1; i <= minuta2; i++){
- count = 0;
- for (int j = 0; j < n; j++)
- if (i >= min1[j] && i <= min2[j]){
- //cout << min1[j] << " " << i << " " << min2[j] << endl;
- count++;
- }
- if (count > max){
- max = count;
- imax = i;
- }
- }
- cout << int(imax/60)<< " " << imax%60;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement