Advertisement
Maxty

jipp 18.10.17

Oct 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. 1....
  2.  
  3. #include <iostream>
  4. #include <math.h>
  5. using namespace std;
  6.  
  7. class odcinek{
  8. public:
  9. double x1,x2,y1,y2;
  10.  
  11. void show(){
  12. cout << "wczytaj x1" <<endl;
  13. cin >> x1;
  14. cout<<"wczytaj y1"<<endl;
  15. cin >> y1;
  16. cout << "wczytaj x2" <<endl;
  17. cin >> x2;
  18. cout<<"wczytaj y2"<<endl;
  19. cin >> y2;
  20. cout<<"x1 wynosi: "<<x1<<endl;
  21. cout<<"y1 wynosi: "<<y1<<endl;
  22. cout<<"x2 wynosi: "<<x2<<endl;
  23. cout<<"y2 wynosi: "<<y2<<endl;
  24. };
  25.  
  26. double odleglosc(){
  27.  
  28. double odleglosc;
  29. odleglosc=(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
  30. return odleglosc;
  31.  
  32. };
  33.  
  34. };
  35.  
  36. /*class punkt{
  37. public:
  38. double x,y;
  39.  
  40. void show(){
  41. cout << "wczytaj x" <<endl;
  42. cin >> x;
  43. cout<<"wczytaj y"<<endl;
  44. cin >> y;
  45. cout<<"x wynosi: "<<x<<endl;
  46. cout<<"y wynosi: "<<y<<endl;
  47. };
  48.  
  49. void odleglosc(){
  50. cout<<"odleglosc miedzy punktami p1 i p2 wynosci"<<endl;
  51. ((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
  52. }
  53.  
  54. };*/
  55.  
  56.  
  57.  
  58. int main() {
  59. odcinek p1;
  60.  
  61. p1.show();
  62. cout<<"odleglosc odcinka"<< p1.odleglosc()<<endl;
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. return 0;
  70. }
  71.  
  72. 2...
  73. #include <iostream>
  74. #include <math.h>
  75. using namespace std;
  76.  
  77. class trojkat{
  78. public:
  79. double x1,x2,x3,y1,y2,y3;
  80.  
  81. void wczytaj(){
  82. cout<< "podaj x,y pierwszego punktu"<<endl;
  83. cin >>x1>>y1;
  84. cout<< "podaj x,y drugiego punktu"<<endl;
  85. cin >>x2>>y2;
  86. cout<< "podaj x,y trzeciego punktu"<<endl;
  87. cin >>x3>>y3;
  88.  
  89. cout<<"pierwszy punkt ma wspolrzedne "<< x1<<","<<y1<<endl;
  90. cout<<"drugi punkt ma wspolrzedne "<< x2<<","<<y2<<endl;
  91. cout<<"trzeci punkt ma wspolrzedne "<< x3<<","<<y3<<endl;
  92. }
  93.  
  94. double obwod(){
  95. double a,b,c,obwod;
  96. a=(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
  97. b=(sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)));
  98. c=(sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)));
  99. obwod=a+b+c;
  100. return obwod;
  101.  
  102. }
  103. double pole(){
  104. double a,b,c,pole,p;
  105. a=(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
  106. b=(sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)));
  107. c=(sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)));
  108. p=(a+b+c)/2.0;
  109. pole=sqrt((p*(p-a)*(p-b)*(p-c)));
  110. return pole;
  111.  
  112. }
  113.  
  114.  
  115. };
  116.  
  117.  
  118.  
  119.  
  120. int main() {
  121. trojkat t1;
  122. t1.wczytaj();
  123. cout<<"obwod trojkata wynosi "<<t1.obwod()<<endl;
  124. cout<<"pole trojkata wynosi "<<t1.pole()<<endl;
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. return 0;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement