Petro_zzz

lesson5_321

Jul 5th, 2023
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void task_aqvarium() {
  6.     cout << "    Аквариум   " << endl;
  7.    
  8.     double width = 4;
  9.     double lenght = 6;
  10.     double height = 2;
  11.    
  12.     //double width=6, lenght=2, height=3;
  13.     /*
  14.     cout << "Введите ширину в дм.:";   
  15.     cin >> width;
  16.     cout << "Введите длинну в дм.:";
  17.     cin >> lenght;
  18.     cout << "Введите высоту в дм.:";
  19.     cin >> height;
  20.     */
  21.     const double price = 30; // rub/litr
  22.     double cost = width * lenght * height * price;
  23.  
  24.     cout << "Цена: " << cost << " рублей." << endl;
  25. }
  26.  
  27. void test_type() {
  28.     cout << "Тестируем преобразование типов" << endl;
  29.     int val = 10;
  30.     cout << typeid(val).name() << " "
  31.          << sizeof(val) << " "
  32.          << val << " "
  33.          << &val << endl;
  34.  
  35.     short i1 = 1;
  36.     int   i2 = 2;
  37.     long  i3 = 3;
  38.     long long i4 = 4;
  39.  
  40.     float  d1 = 12.5;
  41.     double d2 = 13.8;
  42.  
  43.     bool flag = true; // false
  44.     char ch = '+';
  45.     cout << ch << " " << flag << endl;
  46.  
  47.     cout << typeid( 1.0 * 3 / 2 ).name() << " "
  48.          << 1.0 * 3 / 2 << endl;
  49.  
  50.     cout << typeid(1 + ch ).name() << " "
  51.         << 1 + ch << endl;
  52.  
  53.     ch = 200434;
  54.  
  55.     cout << ch;
  56.     cout << ch + 1 << endl;
  57.  
  58.     i2 = 15.6;
  59.     cout << "i2 (15.6) : " << i2 << endl;
  60.  
  61.     int val1 = 65;
  62.     cout << val1 << " " << (char)val1 << endl;
  63.     cout << 98 << " " << (char)98 << endl;
  64.     cout << (double)val1/2 << endl;
  65.  
  66.     cout << (bool)-10 << " "
  67.         << bool(0) << " "
  68.         << (bool)10 << endl;
  69. }
  70.  
  71. void calc_time(int seconds) {
  72.     int hours = seconds / (60 * 60);
  73.     int minutes = (seconds / 60) % 60;
  74.     int sec = seconds % 60;
  75.  
  76.     cout << hours << ":"
  77.         << minutes << ":"
  78.         << sec << endl;
  79. }
  80.  
  81. void task_time() {
  82.     int s = 36000;
  83.     calc_time(s);
  84.     int s2 = 24 * 60 * 60 - s;
  85.     calc_time(s2);
  86. }
  87.  
  88. int main() {
  89.     setlocale(LC_ALL, "ru");   
  90.     //task_aqvarium(); 
  91.     //test_type();
  92.     task_time();
  93.     return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment