Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdafx.h>
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int x, y, x1, y1, x2, y2;
- cin >> x >> y >> x1 >> y1 >> x2 >> y2;
- float l1 = sqrt((float)((x - x1)*(x - x1) + (y - y1)*(y - y1)));
- float l2 = sqrt((float)((x - x2)*(x - x2) + (y - y2)*(y - y2)));
- float l3 = sqrt((float)((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)));
- float p = (l1 + l2 + l3) / 2;
- float s = sqrt((float)(p*(p - l1)*(p - l2)*(p - l3)));
- float h = 2 * s / l3;
- if ((l1*l1 + l3 * l3 - l2 * l2 >= 0) && (l2*l2 + l3 * l3 - l1 * l1 >= 0)) {
- cout << setprecision(4) << fixed << h;
- cout <<"sosi1"<< endl ;
- }
- else {
- cout << "sosi2" << endl;
- if (l1 < l2) {
- cout << setprecision(4) << fixed << l1;
- }
- else {
- cout << setprecision(4) << fixed << l2;
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement