SHARE
TWEET

Untitled

a guest Jun 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include "pch.h"
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. struct Al
  8. {
  9.     int d;
  10. };
  11.  
  12. Al operator + (Al &kill, Al &koll)
  13. {
  14.     Al dill;
  15.     dill.d = kill.d + koll.d;
  16.     return dill;
  17. }
  18.  
  19.  
  20. template < typename T >
  21.  
  22. T clo(T a, T b)
  23. {
  24.     T c;
  25.     c = a + b;
  26.     return c;
  27. }
  28.  
  29. template < class T, size_t size >
  30.  
  31. class Te
  32. {
  33. private:
  34.     T a1[size];
  35. public:
  36.  
  37.     Te()
  38.  
  39.     {
  40.         for (int i=0; i < size; i++)
  41.         {  
  42.             cout << endl << "Vvedite " << i + 1 << " chislo ";
  43.             cin >> a1[i];
  44.         }
  45.     }
  46.  
  47.     void slog()
  48.     {
  49.         for (int i=0; i < size-1; i++)
  50.         {
  51.             a1[0] = a1[0] + a1[i + 1];
  52.         }
  53.         cout << endl << "Rezyltat clogenia= " << a1[0];
  54.     }
  55. };
  56.  
  57. int main()
  58. {
  59.     int s1 = 7, s2 = 18;
  60.     double s3 = 12.3, s4 = 56.23;
  61.     cout << "Skladivaem chials 7 and 18";
  62.     cout << endl << "Otvet=" << clo <int>(s1, s2);
  63.     cout << endl;
  64.     cout << "__________________________________________________________________________";
  65.     cout << endl << endl;
  66.     cout << "Skladivaem chials 12.3 and 56.23";
  67.     cout << endl << "Otvet=" << clo <double >(s3, s4);
  68.     cout << endl;
  69.  
  70.     cout << endl;
  71.     cout << "__________________________________________________________________________";
  72.  
  73.     Te <int, 2> F;
  74.     F.slog();
  75.     cout << endl;
  76.     cout << "__________________________________________________________________________";
  77.  
  78.     Al h;
  79.     Al j;
  80.     h.d = 17;
  81.     j.d = 3;
  82.  
  83.     Al g;
  84.     g = clo <Al>(h, j);
  85.     cout << endl << h.d << "+" << j.d;
  86.     cout << "=" << g.d << endl;
  87.  
  88.     return 0;
  89. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top