Advertisement
noler89

Untitled

Jan 13th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. struct hour{
  5. int h, m;
  6. hour(){
  7. h = 0; // часы
  8. m = 0; // минуты
  9. }
  10. };
  11. int main(int argc, char **argv){
  12. if (argc < 1) {
  13. cout << "Error: not enpugh input arguments" << endl;
  14. return 1;
  15. }
  16. ifstream in;
  17. in.open(argv[1]); // открывает файл с координатами и количеством точек
  18. if (!in.is_open()) // в случае, если файл не открылся
  19. {
  20. cout << "Error: can't open the file" << endl;
  21. return 1;
  22. }
  23. int minuta1=0, minuta2 = 0;
  24. cout << "Vvedite vremya itkriya i zakr";
  25. int h1, m1, h2, m2;
  26. cin >> h1 >> m1 >> h2 >> m2;
  27. minuta1 = h1 * 60 + m1;
  28. minuta2 = h2 * 60 + m2;
  29. int minutes[600]; // обнуляем массив всех минут
  30. for (int i = 0; i < 599; i++)
  31. minutes[i] = 0;
  32. int n;
  33. in >> n;
  34. hour *time1 = new hour[n];
  35. int *min1 = new int[n];
  36. hour *time2 = new hour[n];
  37. int *min2 = new int[n];
  38. for (int j = 0; j < n; j++) {
  39. in >> time1[j].h >> time1[j].m;
  40. min1[j] = time1[j].h * 60 + time1[j].m; // минута входа
  41. in >> time2[j].h >> time2[j].m;
  42. min2[j] = time2[j].h * 60 + time2[j].m; // минута выхода
  43. }
  44. //for (int j = 0; j < n; j++)
  45. //cout << min1[j] << " " << min2[j] << endl;
  46. int count = 0;
  47. int max = 0;
  48. int imax = 0;
  49. for (int i = minuta1; i <= minuta2; i++){
  50. count = 0;
  51. for (int j = 0; j < n; j++)
  52. if (i >= min1[j] && i <= min2[j]){
  53. //cout << min1[j] << " " << i << " " << min2[j] << endl;
  54. count++;
  55. }
  56. if (count > max){
  57. max = count;
  58. imax = i;
  59. }
  60. }
  61. cout << int(imax/60)<< " " << imax%60;
  62. system("pause");
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement