Guest User

Untitled

a guest
Feb 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #include <conio.h>
  2. #include <iostream.h>
  3. #include <iomanip.h>
  4. #include "apstring.h"
  5. #include <math.h>
  6.  
  7. void getpoints(int &s1x, int &s1y, int &s2x, int &s2y, int &s3x, int &s3y);
  8. void calcdist(int s1x, int s1y, int s2x, int s2y, int s3x, int s3y, double &h, double &side1, double &side2);
  9. void displaytype(double h, double side1, double side2);
  10. int main()
  11. {
  12. int s1x, s1y, s2x, s2y, s3x, s3y;
  13. double h, side1, side2;
  14.  
  15. getpoints(s1x, s1y, s2x, s2y, s3x, s3y);
  16. calcdist(s1x, s1y, s2x, s2y, s3x, s3y, h, side1, side2);
  17. displaytype(h, side1, side2);
  18.  
  19. getch();
  20. return 0;
  21. }
  22.  
  23. void getpoints(int &s1x, int &s1y, int &s2x, int &s2y, int &s3x, int &s3y)
  24. {
  25. cout<<"Enter the coordinates for point one (x then y) hitting enter after each one."<<endl;
  26. cin>>s1x;
  27. cin>>s1y;
  28. cout<<"Enter the coordinates for point two (x then y) hitting enter after each one."<<endl;
  29. cin>>s2x;
  30. cin>>s2y;
  31. cout<<"Enter the coordinates for point three (x then y) hitting enter after each one."<<endl;
  32. cin>>s3x;
  33. cin>>s3y;
  34. }
  35. void calcdist(int s1x, int s1y, int s2x, int s2y, int s3x, int s3y, double &h, double &side1, double &side2)
  36. {
  37. double d1,d2,d3;
  38. d1=sqrt(pow((s2x-s1x),2)+pow((s2y-s1y),2));
  39. d2=sqrt(pow((s3x-s2x),2)+pow((s3y-s2y),2));
  40. d3=sqrt(pow((s3x-s1x),2)+pow((s3y-s1y),2));
  41. if(d1>=d2 && d1>=d3)
  42. {h=d1;
  43. side1=d2;
  44. side2=d3;
  45. }
  46. else if(d2>=d1 && d2>=d3)
  47. {h=d2;
  48. side1=d1;
  49. side2=d3;
  50. }
  51. else if(d3>=d2 && d3>=d1)
  52. {h=d3;
  53. side1=d1;
  54. side2=d2;
  55. }
  56. cout<<h<<" "<<side1<<" "<<side2<<endl;
  57. }
  58. void displaytype(double h, double side1, double side2)
  59. {
  60. side1 = double(int(side1*10.00))/10.00;
  61. side2 = double(int(side2*10.00))/10.00;
  62. h = double(int(h*10.00))/10.00;
  63. if(((side2*side2)+(side1*side1))>(h*h))
  64. {
  65. cout<<" "<<endl;
  66. cout<<"acute"<<endl;
  67. cout<<(side2*side2)+(side1*side1)<<" "<<(h*h)<<endl;
  68. }
  69.  
  70. else if(((side1*side1)+(side2*side2))<(h*h))
  71. {
  72. cout<<" "<<endl;
  73. cout<<"obtuse"<<endl;
  74. }
  75. else
  76. {
  77. cout<<" "<<endl;
  78. cout<<"right"<<endl;
  79. }
  80. }
Add Comment
Please, Sign In to add comment