Advertisement
mercMatvey4

Untitled

May 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. class Otrezok{
  6. int x1;
  7. int y1;
  8. int z1;
  9. int x2;
  10. int y2;
  11. int z2;
  12. public:
  13. Otrezok () {x1 = 0; y1 = 0; z1 = 0; x2 = 0; y2 = 0; z2 = 0;}
  14. Otrezok (int i, int j, int k, int a, int b, int c) {x1 = i; y1 = j; z1 = k; x2 = a; y2 = b; z2 = c;}
  15. float dlina() {return sqrt((pow(x2-x1,2))+(pow(y2-y1,2))+(pow(z2-z1,2)));}
  16. int get_x1() {return x1;}
  17. int get_x2() {return x2;}
  18. int get_y1() {return y1;}
  19. int get_y2() {return y2;}
  20. int get_z1() {return z1;}
  21. int get_z2() {return z2;}
  22. };
  23.  
  24. Otrezok Max(Otrezok arr[]){
  25. Otrezok temp;
  26. for (int i = 0; i < 6; i++) {
  27. for (int j = 0; j < 6; j++) {
  28. if (arr[j].dlina() > arr[j+1].dlina()) {
  29. temp = arr[j];
  30. arr[j] = arr[j+1];
  31. arr[j+1] = temp;
  32. }
  33. }
  34. }
  35. return temp;
  36. }
  37.  
  38. int main()
  39. {
  40. setlocale(LC_ALL,"");
  41. Otrezok obj[6];
  42. for (int i = 0; i < 6; i++)
  43. {
  44. int a, b, c, d, e, f;
  45. cin >> a >> b >> c >> d >> e >> f;
  46. Otrezok temp(a,b,c,d,e,f);
  47. obj[i] = temp;
  48. }
  49. Otrezok maximum();
  50. maximum = Max(obj[6]);
  51. cout << "Координаты самого большого отрезка : \n";
  52. cout << maximum.get_x1() << maximum.get_x2() << endl;
  53. cout << maximum.get_y1() << maximum.get_y2() << endl;
  54. cout << maximum.get_z1() << maximum.get_z2() << endl;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement