Advertisement
35657

Untitled

Mar 15th, 2024
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <typename T>
  6. T Abs(T num) {
  7.     return num < 0 ? -num : num;
  8. }
  9.  
  10.  
  11.  
  12. int main() {
  13.  
  14.     setlocale(LC_ALL, "ru");
  15.  
  16.     cout << Abs(-1) << endl;
  17.     cout << Abs(5.35) << endl;
  18.     cout << Abs(-4.2) << endl;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement