fork download
  1.  
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <cmath>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. void print(int hh, int mm)
  10. {
  11. char hzero, mzero;
  12. while (mm >=60 || hh >=24)
  13. {
  14. if (mm >= 60)
  15. {
  16. mm -= 60;
  17. hh++;
  18. }
  19. if (hh >= 24)
  20. hh -= 24;
  21. }
  22. if(hh<10&&mm>=10)
  23. cout << ",0"<< hh << ":" << mm;
  24. else if (hh<10 && mm <10)
  25. cout << ",0" << hh << ":0" << mm;
  26. else if (hh>10 && mm <10)
  27. cout << "," << hh << ":0" << mm;
  28. else if (hh>10 && mm >10)
  29. cout << "," << hh << ":" << mm;
  30. }
  31.  
  32. int main()
  33. {
  34. string start;
  35. int br;
  36. cin >> start;
  37. int mm, hh;
  38. if (start.length() < 5)
  39. start = "0" + start;
  40. hh = (start[0] - '0') * 10 + (start[1] - '0');
  41. mm= (start[3] - '0') * 10 + (start[4] - '0');
  42. cout << start;
  43. while (cin>>br)
  44. {
  45. mm += 45;
  46. print(hh, mm);
  47. mm += br;
  48. if(br!=0)
  49. print(hh, mm);
  50. }
  51. mm += 45;
  52. print(hh, mm);
  53. return 0;
  54. }
  55.  
  56.  
Success #stdin #stdout 0s 4444KB
stdin
8:00
stdout
08:00,08:45