Advertisement
Guest User

Untitled

a guest
May 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include <fstream>
  2. #include <iomanip>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. class Time {
  8. private:
  9. int h,min,s,sec;
  10. public:
  11. Time(): h(0), min(0), s(0) {}
  12. Time(int x,int y,int z): h(x), min(y), s(z) {}
  13. ~Time() {}
  14. void Ivedimas()
  15. {
  16. cin >> h >> min >> s;
  17. }
  18. void Skaiciavimas()
  19. {
  20. sec = (((h*60)+min)*60+s);
  21. }
  22. int graz_sekundes()
  23. {
  24. return sec;
  25. }
  26. };
  27. int main() {
  28.  
  29. int n, h, s, min;
  30. int max = -10000000, maxi = -10;
  31.  
  32. cin >> n;
  33.  
  34. Time T[100];
  35.  
  36. for (int i = 0; i < n; i++)
  37. {
  38. T[i].Ivedimas();
  39. T[i].Skaiciavimas();
  40. }
  41. for(int i = 0; i < n; i++)
  42. {
  43. for(int j = 0; j < n; j++)
  44. {
  45. maxi = T[i].graz_sekundes() + T[j].graz_sekundes();
  46. if(maxi >= 86400)
  47. {
  48. maxi = maxi-86400;
  49. }
  50. if(i!=j && maxi > max)
  51. {
  52. max=maxi;
  53. }
  54. }
  55. }
  56.  
  57. h = max/3600;
  58. min = (max-h*3600)/60;
  59. s = max%60;
  60.  
  61.  
  62.  
  63.  
  64. if((h<=9&&min<=9)&&s<=9)
  65. cout<<"0"<< h << ":"<<"0"<< min << ":"<<"0"<< s << endl;
  66. if((h<=9&&min<=9)&&s>=10)
  67. cout<<"0"<< h << ":"<<"0"<< min << ":"<<s << endl;
  68. if((h<=9&&min>=10)&&s<=9)
  69. cout<<"0"<<h<<":"<<min<<":"<<"0"<<s<<endl;
  70. if((h<=9&&min>=10)&&s>=10)
  71. cout<<"0"<< h << ":"<< min<< ":"<< s << endl;
  72. if((h>=10&&min>=10)&&s>=10)
  73. cout<< h << ":"<< min << ":"<< s << endl;
  74. if((h>=10&&min>=10)&&s<=9)
  75. cout<< h << ":"<< min<< ":"<<"0"<< s << endl;
  76. if((h>=10&&min<=9)&&s<=9)
  77. cout<< h << ":"<<"0"<< min<< ":"<<"0"<< s << endl;
  78. if((h>=10&&min<=9)&&s>=10)
  79. cout<< h << ":"<<"0"<< min<< ":"<< s << endl;
  80.  
  81.  
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement