Advertisement
Guest User

Untitled

a guest
May 29th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. duota n 3x3 matricų. rasti determinantų sumą ir vidurkį
  2. elementus iš klaviatūros
  3. 1) butina klase
  4. 2) destruktoriai all that shit
  5. 3) rodykles ir dinamine atmintis
  6.  
  7.  
  8. #include <iostream>
  9. #include <cstdlib>
  10. using namespace std;
  11.  
  12. class Determinantas
  13. {
  14. private:
  15. int x1, x2, x3, y1, y2, y3, z1, z2, z3;
  16. double determinantas;
  17. public:
  18. Determinantas() : x1(0), x2(0), x3(0), y1(0), y2(0), y3(0), z1(0), z2(0), z3(0) {}
  19. Determinantas (int a, int b, int c, int d, int e, int f, int g, int h, int i) : x1(a), x2(b), x3(c), y1(d), y2(e), y3(f), z1(g), z2(h), z3(f){}
  20. ~Determinantas(){}
  21. //
  22. void Ivedimas()
  23. {
  24. cout << "Iveskite matricos elementus: \n";
  25. cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> x3 >> y3 >> z3;
  26. }
  27. void showData()
  28. {
  29. cout << "Matrica atrodo taip: \n";
  30. cout << x1 << " " << y1 << " " << z1 << " \n";
  31. cout << x2 << " " << y2 << " " << z2 << " \n"
  32. cout << x3 << " " << y3 << " " << z3 << " \n"
  33. }
  34. int Skaiciavimas()
  35. {
  36.  
  37. determinantas = (x1*y2*z3)+(y1*z2*x3)+(z1*x2*y3)-(z1*y2*x3)-(y1*x2*z3)-(x1*z2*y3);
  38. return determinantas;
  39. }
  40. };
  41.  
  42. int maint ()
  43. {
  44. int n, suma=0;
  45. double vidurkis=0;
  46. cout << "Iveskite matricu skaiciu: \n";
  47. cin >> n
  48. Determinantas *matrix = new Determinantas[n]; // *matrix - rodykle // new Determinans[n] // sukuriama dinamine atmintis
  49. for (int i = 0; i++; i<n)
  50. {
  51. matrix[i].Ivedimas();
  52. matrix[i].showData();
  53. matrix[i].Skaiciavimas();
  54. suma = suma + matrix[i].skaiciavimas();
  55. }
  56. vidurkis = suma / n;
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement