Advertisement
VEGASo

Lab #5 Ex. 3

Nov 5th, 2022
834
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <limits>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. void closureMin(int, int def = 3)
  8. {
  9.     cout << "\n\nInt на минимальном значении: \n";
  10.     for (int i = def; i >= -def; i--) // на минимальном
  11.     {
  12.         if (i >= 0)
  13.             cout << static_cast<int>(numeric_limits<int>::min()) << "+" << i << " = " << static_cast<int>(numeric_limits<int>::min() + i) << endl;
  14.         else if (i < 0)
  15.             cout << static_cast<int>(numeric_limits<int>::min()) << i << " = " << static_cast<int>(numeric_limits<int>::min() - i) << endl;
  16.     }
  17.  
  18.     cout << "\nInt на максимальном значении: \n";
  19.     for (int i = def; i >= -def; i--) // на максимальном
  20.     {
  21.         if (i >= 0)
  22.             cout << static_cast<int>(numeric_limits<int>::max()) << "+" << i << " = " << static_cast<int>(numeric_limits<int>::max() + i) << endl;
  23.         else if (i < 0)
  24.             cout << static_cast<int>(numeric_limits<int>::max()) << i << " = " << static_cast<int>(numeric_limits<int>::max() - i) << endl;
  25.     }
  26. }
  27.  
  28. void closureMin(char, int def = 3)
  29. {
  30.     cout << "\n\nChar на минимальном значении: \n";
  31.     for (int i = def; i >= -def; i--) // на минимальном
  32.     {
  33.         if (i >= 0)
  34.             cout << static_cast<int>(numeric_limits<char>::min()) << "+" << i << " = " << static_cast<int>(numeric_limits<char>::min() + i) << endl;
  35.         else if (i < 0)
  36.             cout << static_cast<int>(numeric_limits<char>::min()) << i << " = " << static_cast<int>(numeric_limits<char>::min() - i) << endl;
  37.     }
  38.  
  39.     cout << "\nChar на максимальном значении: \n";
  40.     for (int i = def; i >= -def; i--) // на максимальном
  41.     {
  42.         if (i >= 0)
  43.             cout << static_cast<int>(numeric_limits<char>::max()) << "+" << i << " = " << static_cast<int>(numeric_limits<char>::max() + i) << endl;
  44.         else if (i < 0)
  45.             cout << static_cast<int>(numeric_limits<char>::max()) << i << " = " << static_cast<int>(numeric_limits<char>::max() - i) << endl;
  46.     }
  47. }
  48.  
  49.  
  50. //void closureMin( (и так далее) , int def = 3)
  51.  
  52.  
  53. int main()
  54. {
  55.     setlocale(LC_ALL, "RU");
  56.  
  57.     int print{ 0 };
  58.  
  59.     cout << "Введите количество шагов (по дефолту стоит 3): ";
  60.     cin >> print;
  61.  
  62.     closureMin(int{ 0 }, print);
  63.     closureMin(char{ 0 }, print);
  64.     //closureMin( (и так далее) { 0 }, print);
  65.  
  66.     return 0;
  67. }
  68.  
Advertisement
Comments
  • jshokova
    1 year
    # text 0.21 KB | 0 0
    1. //void closureMin( (и так далее) , int def = 3)
    2. а доделать?
    3.  
    4. static_cast<int>(numeric_limits<char>::min() - i)
    5. вот это для чара замыкание вам не покажет
    6.  
Add Comment
Please, Sign In to add comment
Advertisement