Facebook
From aaa, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 149
  1. #include <iostream>
  2. using namespace std;
  3. template <typename Typ>
  4. Typ max(const Typ &a, const Typ &b, const Typ &c)
  5. {
  6.         if (a > b)
  7.         {
  8.                 if (a > c)
  9.                         return a;
  10.                 else
  11.                         return c;
  12.         }
  13.         else
  14.         {
  15.                 if (b > c)
  16.                         return b;
  17.                 else return c;
  18.         }
  19. }
  20. template <typename Typ>
  21. Typ walec(const Typ &r, const Typ &h)
  22. {
  23.         return ((2*3.14*r*r)+(2*3.14*r*h));
  24. }
  25. int main()
  26. {
  27.         int x = 2, y = 5, z = 4;
  28.         cout << "najwieksza wartosc to: " << max(x, y, z) << endl;
  29.        
  30.         int a = 2, b = 5;
  31.         cout << " pole powierzchni walca: " << walec(a, b) << endl;
  32.         float c = 2.1, d = 5.1;
  33.         cout << " pole powierzchni walca: " << walec(c, d) << endl;
  34.         long long int e = 2201212, f = 5133434;
  35.         cout << " pole powierzchni walca: " << walec(e, f) << endl;
  36.         cin >> x;
  37. }