Advertisement
MeehoweCK

Untitled

Dec 10th, 2020
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     double Ax, Ay, Bx, By, d, b, x1, y1;
  10.     char komenda;
  11.  
  12.     do
  13.     {
  14.         system("cls");
  15.         cout << "Podaj wspolrzedne punktu A: ";
  16.         cin >> Ax >> Ay;
  17.         cout << "Podaj wspolrzedne punktu B: ";
  18.         cin >> Bx >> By;
  19.         cout << "Podaj odleglosc od punktu A: ";
  20.         cin >> b;
  21.  
  22.         d = pow((Bx - Ax)*(Bx - Ax) + (By - Ay)*(By - Ay), 0.5);
  23.  
  24.         x1 = Ax + b * (Bx - Ax) / d;
  25.         y1 = Ay + b * (By - Ay) / d;
  26.  
  27.         cout << "Szukany punkt to (" << x1 << ',' << y1 << ")\n";
  28.  
  29.         cout << "Czy kontynuowac? (t/n) ";
  30.         do
  31.         {
  32.             komenda = getch();
  33.             komenda = toupper(komenda);
  34.         } while(komenda != 'T' && komenda != 'N');
  35.     } while(komenda == 'T');
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement