Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #include <math.h>
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #include <time.h>
  5. #include <Windows.h>
  6.  
  7. unsigned int time_sec(unsigned int h, unsigned int m, unsigned int s);
  8.  
  9. int main() {
  10.  
  11.   SetConsoleCP(1251);
  12.   SetConsoleOutputCP(1251);
  13.   srand(time(0));
  14.  
  15.   int a = time_sec(10, 15, 36);
  16.   int b = time_sec(14, 59, 23);
  17.  
  18.   printf("Кіл-сть секунд першого моменту часу: %d\n", a);
  19.   printf("Кіл-сть секунд другого моменту часу: %d\n\n", b);
  20.  
  21.   if (a > b)
  22.     printf("Oбчислення проміжку часу у секундах між двома моментами: %d", a - b);
  23.   else
  24.     printf("Oбчислення проміжку часу у секундах між двома моментами: %d", b - a);
  25.  
  26.   _getch();
  27.   return 0;
  28. }
  29.  
  30. unsigned int time_sec(unsigned int h, unsigned int m, unsigned int s)
  31. {
  32.   return (h % 12) * 3600 + m * 60 + s;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement