fork(4) download
  1. #include <string>
  2. #include <sstream>
  3. #include <iomanip>
  4. #include <iostream>
  5.  
  6. std::string whatTime(const int seconds_n)
  7. {
  8. std::stringstream ss;
  9.  
  10. const int hours = seconds_n / 3600;
  11. const int minutes = (seconds_n / 60) % 60;
  12. const int seconds = seconds_n % 60;
  13.  
  14. ss << std::setfill('0');
  15. ss << std::setw(2) << hours << ':'
  16. << std::setw(2) << minutes << ':'
  17. << std::setw(2) << seconds;
  18.  
  19. return ss.str();
  20. }
  21.  
  22. int main()
  23. {
  24. std::cout
  25. << whatTime(15) << ','
  26. << whatTime(30) << ','
  27. << whatTime(59) << ','
  28. << whatTime(60) << ','
  29. << whatTime(61) << ','
  30. << whatTime(119) << ','
  31. << whatTime(120) << ','
  32. << whatTime(121) << ','
  33. << whatTime(250) << ','
  34. << whatTime(350) << ','
  35. << whatTime(800) << ','
  36. << whatTime(1200) << ','
  37. << whatTime(35000) << '\n';
  38. }
Success #stdin #stdout 0s 3024KB
stdin
Standard input is empty
stdout
00:00:15,00:00:30,00:00:59,00:01:00,00:01:01,00:01:59,00:02:00,00:02:01,00:04:10,00:05:50,00:13:20,00:20:00,09:43:20