fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. string toString(int x){
  6. string s;
  7. s += (char)(x/10%10 + '0');
  8. s += (char)(x%10 + '0');
  9. return s;
  10. }
  11.  
  12. void inc(int &h, int &m) {
  13. m++;
  14. if (m == 60) {
  15. ++h;
  16. m = 0;
  17. if (h == 24) {
  18. h = 0;
  19. }
  20. }
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26. string s;
  27. int a;
  28. cin >> s >> a;
  29. int h = (s[0]-'0') * 10 + s[1]-'0';
  30. int m = (s[3]-'0') * 10 + s[4]-'0';
  31.  
  32. for (int i = 1; i <= a; ++i) {
  33. inc(h, m);
  34. }
  35.  
  36. cout << toString(h) << ":" << toString(m);
  37. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
./:41