Advertisement
mrAnderson33

Untitled

Apr 25th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include<iostream>
  2. #include <ctime>
  3.  
  4. typedef int temperature;
  5.  
  6. int main()
  7. {
  8.     temperature T_curr = 10;// Текущая температура
  9.     temperature T_set1 = 20;
  10.     temperature T_set2 = 40;
  11.  
  12.     unsigned int start_time = clock(); // начальное время
  13.     unsigned int switching_time = 100; // количество секунд перед переключением времени
  14.     unsigned int endinging_time = 100; // время через которое процесс завершается
  15.  
  16.     while (true)
  17.     {
  18.         unsigned int end_time = clock(); // конечное время
  19.         unsigned int search_time = end_time - start_time; // искомое время
  20.         unsigned int working_time = end_time - start_time - switching_time;
  21.  
  22.         if (search_time < switching_time)
  23.         {
  24.             T_curr = T_set1;
  25.         }
  26.         else if(working_time < endinging_time)
  27.         {
  28.             T_curr = T_set2;
  29.         }
  30.         else
  31.         {
  32.             break;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement