Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <limits>
- using namespace std;
- template <typename T>
- void closureMin(int def = 3)
- {
- cout << "\nЗамыкание в " << typeid(T).name() << "\n";
- cout << "\nНа минимальном значении: \n";
- for (int i = def; i >= -def; i--) // на минимальном
- {
- if (i >= 0)
- cout << static_cast<int>(numeric_limits<T>::min()) << "+" << i << " = " << static_cast<int>(numeric_limits<T>::min() + i) << endl;
- else if (i < 0)
- cout << static_cast<int>(numeric_limits<T>::min()) << i << " = " << static_cast<int>(numeric_limits<T>::min() - i) << endl;
- }
- cout << "\nНа максимальном значении: \n";
- for (int i = def; i >= -def; i--) // на максимальном
- {
- if (i >= 0)
- cout << static_cast<int>(numeric_limits<T>::max()) << "+" << i << " = " << static_cast<int>(numeric_limits<T>::max() + i) << endl;
- else if (i < 0)
- cout << static_cast<int>(numeric_limits<T>::max()) << i << " = " << static_cast<int>(numeric_limits<T>::max() - i) << endl;
- }
- }
- int main()
- {
- setlocale(LC_ALL, "RU");
- closureMin<int>();
- closureMin<unsigned int>();
- closureMin<long>();
- closureMin<unsigned long>();
- closureMin<long long>();
- closureMin<unsigned long long>();
- closureMin<char>();
- closureMin<unsigned char>();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement