Advertisement
Paszta

Obiektówka laby3 zad 1,2, koło (ndk), trojkat (ndk)

Oct 23rd, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. class punkty{
  7.     float x, y;
  8.  
  9. public:
  10.     punkty( float x1, float y1){
  11.  
  12.         x=x1;
  13.         y=y1;
  14.     }
  15.     void wektor(){
  16.  
  17.         cout << "Wspolrzedne wektora to: " << "(" << x << "," << y << ")" << endl;
  18.     }
  19.     float odleglosc(){
  20.         float odl;
  21.         odl = sqrt(x*x + y*y );
  22.         return odl;
  23.         }
  24.     void osX(){
  25.         if(y == 0) cout << "Punkt nalezy do osi X" << endl;
  26.         else cout << "Punkt nie nalezy do do osi X" << endl;
  27.     }
  28.     void osY(){
  29.         if (x == 0) cout << "Punkt nalezy do osi Y" << endl;
  30.         else cout << "Punkt nie nalezy do osi Y" << endl;
  31.     }
  32.  
  33.     int cwiartka(){
  34.         if (x > 0 and y > 0 ) return 1;
  35.         if (x < 0 and y > 0) return 2;
  36.         if (x < 0 and y < 0) return 3;
  37.         if (x > 0 and y < 0) return 4;
  38.     }
  39. };
  40.  
  41. int main()
  42. {
  43.     int p1, p2;
  44.     cout << "Pierwsza wspolrzedna " << endl;
  45.     cin >> p1;
  46.     cout << "Druga wspolrzedna " << endl;
  47.     cin >> p2;
  48.     punkty A(p1, p2);
  49.     A.wektor();
  50.     cout << "Odleglosc punktu od (0,0) wynosi: " << A.odleglosc() << endl;
  51.     A.osX();
  52.     A.osY();
  53.     cout << "Punkt znajduje sie w cwiartce :" << A.cwiartka() << endl;
  54. return 0;
  55. }
  56.  
  57. 2. ale nie do konca dziala chyba
  58.  
  59. #include <iostream>
  60. #include <math.h>
  61.  
  62. using namespace std;
  63.  
  64. class punkty{
  65.     float x, y;
  66.  
  67. public:
  68.     punkty( float x1, float y1){
  69.  
  70.         x=x1;
  71.         y=y1;
  72.     }
  73.     void wektor(){
  74.  
  75.         cout << "Wspolrzedne wektora to: " << "(" << x << "," << y << ")" << endl;
  76.     }
  77.     float odleglosc(){
  78.         float odl;
  79.         odl = sqrt(x*x + y*y );
  80.         return odl;
  81.         }
  82.     void osX(){
  83.         if(y == 0) cout << "Punkt nalezy do osi X" << endl;
  84.         else cout << "Punkt nie nalezy do do osi X" << endl;
  85.     }
  86.     void osY(){
  87.         if (x == 0) cout << "Punkt nalezy do osi Y" << endl;
  88.         else cout << "Punkt nie nalezy do osi Y" << endl;
  89.     }
  90.  
  91.     int cwiartka(){
  92.         if (x > 0 and y > 0 ) return 1;
  93.         if (x < 0 and y > 0) return 2;
  94.         if (x < 0 and y < 0) return 3;
  95.         if (x > 0 and y < 0) return 4;
  96.     }
  97.  
  98.     float getX(){  //AKCESORY
  99.         return x;
  100.     }
  101.     float getY(){
  102.         return y;
  103.     }
  104.     float odleglosc_podanych_punktow(float x2, float y2);
  105. };
  106.  
  107. float punkty::odleglosc_podanych_punktow(float x2, float y2){
  108.     float odl_pod_pun;
  109.     odl_pod_pun = sqrt(pow(x2-x, 2)+ pow(y2-y, 2));
  110.     return odl_pod_pun;
  111. }
  112.  
  113. int main()
  114. {
  115.     punkty A(3, 4);
  116.     punkty B(12, 13);
  117.     A.wektor();
  118.     cout << "Odleglosc punktu od (0,0) wynosi: " << A.odleglosc() << endl;
  119.     A.osX();
  120.     A.osY();
  121.     cout << "Punkt znajduje sie w cwiartce :" << A.cwiartka() << endl;
  122.     cout << " Odleglosc miedzy A i B wynosi: "  << A.odleglosc_podanych_punktow(B.getX(), B.getY()) << endl;
  123.  
  124.  
  125. return 0;
  126. }
  127.  
  128. 3.
  129.  
  130. #include <iostream>
  131. #include <math.h>
  132.  
  133. using namespace std;
  134.  
  135. class kolo{
  136.     float promien_kola;
  137.     int kolor_wypelnienia;
  138.    
  139.     kolo(){
  140.         float promien, kolor;
  141.         promien_kola = promien;
  142.         kolor_wypelnienia = kolor;
  143.     }
  144. }
  145.  
  146. int main()
  147. {
  148.     cout << "Hello World!" << endl;
  149.     return 0;
  150. }
  151.  
  152. /*
  153.  * utworzyc trojkat o trzech wspolrzecnych typu punkt, policzyc pole powierzchni ze wzoru Herona
  154.  */
  155.  
  156. 4. TROJKAT
  157.  
  158.  
  159. #include <iostream>
  160. #include <math.h>
  161.  
  162. using namespace std;
  163.  
  164. class punkty{
  165.     float x, y;
  166.  
  167. public:
  168.     punkty( float x1, float y1){
  169.  
  170.         x=x1;
  171.         y=y1;
  172.     }
  173.     void wektor(){
  174.  
  175.         cout << "Wspolrzedne wektora to: " << "(" << x << "," << y << ")" << endl;
  176.     }
  177.     float odleglosc(){
  178.         float odl;
  179.         odl = sqrt(x*x + y*y );
  180.         return odl;
  181.         }
  182.     void osX(){
  183.         if(y == 0) cout << "Punkt nalezy do osi X" << endl;
  184.         else cout << "Punkt nie nalezy do do osi X" << endl;
  185.     }
  186.     void osY(){
  187.         if (x == 0) cout << "Punkt nalezy do osi Y" << endl;
  188.         else cout << "Punkt nie nalezy do osi Y" << endl;
  189.     }
  190.  
  191.     int cwiartka(){
  192.         if (x > 0 and y > 0 ) return 1;
  193.         if (x < 0 and y > 0) return 2;
  194.         if (x < 0 and y < 0) return 3;
  195.         if (x > 0 and y < 0) return 4;
  196.     }
  197. };
  198.  
  199. class trojkat{
  200.     punkty A, B, C;
  201.    
  202.    
  203. }
  204.  
  205. int main()
  206. {
  207.     int p1, p2;
  208.     cout << "Pierwsza wspolrzedna " << endl;
  209.     cin >> p1;
  210.     cout << "Druga wspolrzedna " << endl;
  211.     cin >> p2;
  212.     punkty A(p1, p2);
  213.     A.wektor();
  214.     cout << "Odleglosc punktu od (0,0) wynosi: " << A.odleglosc() << endl;
  215.     A.osX();
  216.     A.osY();
  217.     cout << "Punkt znajduje sie w cwiartce :" << A.cwiartka() << endl;
  218. return 0;
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement