Advertisement
Courbe_Impliquee

TimeToHMS

Apr 12th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. // ConsoleApplication38.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <clocale>
  7. using namespace std;
  8. void TimeToHMS(int *T, int *H, int *M, int *S){
  9. *H = *T / 3600;
  10. *T = *T % 3600;
  11. *M = *T / 60;
  12. *S = *T % 60;
  13. }
  14.  
  15. int _tmain(int argc, _TCHAR* argv[])
  16. {
  17. setlocale(LC_ALL, "rus");
  18. int T, H = 0, M = 0, S = 0;
  19. for (int i = 1; i <= 5; i++){
  20. cout << "Введите T" << i << ":";
  21. cin >> T;
  22. if (T >= 0){
  23. TimeToHMS(&T, &H, &M, &S);
  24. cout << "В " << T << " секундах: " << endl << H << " часов" << endl << M << " минут" << endl << S << " секунд" << endl;
  25. }
  26. else cout << "error";
  27. }
  28. system("pause");
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement