Advertisement
VEGASo

Lab #2 Ex. 4

Oct 25th, 2022
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. ///////////////////////////////////////////////////////// Lab 2 Ex.4.cpp
  2. //module Convert;
  3. import Convert;
  4. #include <iostream>
  5.  
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main()
  11. {
  12.     setlocale(LC_ALL, "Russian");
  13.  
  14.     int x, chose = 0;
  15.  
  16.     while (chose == 0 || chose > 6 || chose < 0)
  17.     {
  18.         cout << "1. Годы в дни\n2. Дни в часы\n3. Дни в минуты\n4. Часы в минуты\n5. Часы в секунды\n6. Минуты в секунды\n\nВыбирите действие: ";
  19.         cin >> chose;
  20.     }
  21.  
  22.  
  23.     if (chose == 1)
  24.     {
  25.         cout << "\nГода: ";
  26.         cin >> x;
  27.         cout << YearsToDays(x) << " дней\n";
  28.     }
  29.     else if (chose == 2)
  30.     {
  31.         cout << "\nДни: ";
  32.         cin >> x;
  33.         cout << DaysToHour(x) << " часов\n";
  34.     }
  35.     else if (chose == 3)
  36.     {
  37.         cout << "\nДни: ";
  38.         cin >> x;
  39.         cout << DaysToMinutes(x) << " минут\n";
  40.     }
  41.     else if (chose == 4)
  42.     {
  43.         cout << "\nЧасы: ";
  44.         cin >> x;
  45.         cout << HourToMin(x) << " Минут\n";
  46.     }
  47.     else if (chose == 5)
  48.     {
  49.         cout << "\nЧасы: ";
  50.         cin >> x;
  51.         cout << HourToSec(x) << " секунд\n";
  52.     }
  53.     else if (chose == 6)
  54.     {
  55.         cout << "\nМинуты: ";
  56.         cin >> x;
  57.         cout << MinToSec(x) << " секунд\n";
  58.     }
  59.  
  60.  
  61.     return 0;
  62. }
  63. //////////////////////////////////////////////////////
  64.  
  65.  
  66. /////////////////////////////////////////////////////  Convert.ixx
  67. #include <iostream>
  68. export module Convert;
  69.  
  70.  
  71. export int YearsToDays(int x)
  72. {
  73.     return x * 365;
  74. }
  75.  
  76. export int DaysToHour(int x) // Конвертируем дни в часы
  77. {
  78.     return 24 * x;
  79. }
  80.  
  81. export int HourToMin(int x)
  82. {
  83.     return 60 * x;
  84. }
  85.  
  86. export int DaysToMinutes(int x)
  87. {
  88.     return DaysToHour(HourToMin(x));
  89. }
  90.  
  91. export int MinToSec(int x)
  92. {
  93.     return 60 * x;
  94. }
  95.  
  96. export int HourToSec(int x)
  97. {
  98.     return HourToMin(MinToSec(x));
  99. }
  100. ///////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement