Advertisement
Guest User

Trikampis

a guest
Dec 11th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <cmath>
  2. #include <fstream>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. void atstumas (double x1, double y1, double x2, double y2, double &e);
  8. void plotas (double atkarpa1, double atkarpa2, double atkarpa3, double &s);
  9.  
  10. int main (){
  11. ifstream duom("duomenys.txt");
  12. ofstream rez("rezultatai.txt");
  13. double ax, ay, bx, by, cx, cy, xt, yt, AB, BC, AC, AD, BD, DC, ABC, DBC, DAC, DAB, plotsum;
  14. duom>>ax>>ay>>bx>>by>>cx>>cy>>xt>>yt;
  15. atstumas (ax, ay, bx, by, AB);
  16. atstumas (ax, ay, cx, cy, AC);
  17. atstumas (bx, by, cx, cy, BC);
  18. atstumas (bx, by, xt, yt, BD);
  19. atstumas (xt, yt, cx, cy, DC);
  20. atstumas (ax, ay, xt, yt, AD);
  21. plotas (AB, AC, BC, ABC);
  22. plotas (AD, AB, BD, DAB);
  23. plotas (AD, DC, AC, DAC);
  24. plotas (BD, BC, DC, DBC);
  25. plotsum=DAB+DAC+DBC;
  26. if (ABC == plotsum) rez<<"Taskas yra trikampio viduje"<<endl;
  27. else rez<<"Taskas yra trikampio isoreje"<<endl;
  28.  
  29. }
  30. void atstumas (double x1, double y1, double x2, double y2, double &e){
  31. e=sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
  32. }
  33. void plotas (double atkarpa1, double atkarpa2, double atkarpa3, double &s){
  34. double p;
  35. p=(atkarpa1+atkarpa2+atkarpa3)/2;
  36. s=sqrt(p*(p-atkarpa1)*(p-atkarpa2)*(p-atkarpa3));
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement