Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream.h>
- #include <iomanip.h>
- #include "apstring.h"
- #include <math.h>
- void getpoints(int &s1x, int &s1y, int &s2x, int &s2y, int &s3x, int &s3y);
- void calcdist(int s1x, int s1y, int s2x, int s2y, int s3x, int s3y, double &h, double &side1, double &side2);
- void displaytype(double h, double side1, double side2);
- int main()
- {
- int s1x, s1y, s2x, s2y, s3x, s3y;
- double h, side1, side2;
- getpoints(s1x, s1y, s2x, s2y, s3x, s3y);
- calcdist(s1x, s1y, s2x, s2y, s3x, s3y, h, side1, side2);
- displaytype(h, side1, side2);
- getch();
- return 0;
- }
- void getpoints(int &s1x, int &s1y, int &s2x, int &s2y, int &s3x, int &s3y)
- {
- cout<<"Enter the coordinates for point one (x then y) hitting enter after each one."<<endl;
- cin>>s1x;
- cin>>s1y;
- cout<<"Enter the coordinates for point two (x then y) hitting enter after each one."<<endl;
- cin>>s2x;
- cin>>s2y;
- cout<<"Enter the coordinates for point three (x then y) hitting enter after each one."<<endl;
- cin>>s3x;
- cin>>s3y;
- }
- void calcdist(int s1x, int s1y, int s2x, int s2y, int s3x, int s3y, double &h, double &side1, double &side2)
- {
- double d1,d2,d3;
- d1=sqrt(pow((s2x-s1x),2)+pow((s2y-s1y),2));
- d2=sqrt(pow((s3x-s2x),2)+pow((s3y-s2y),2));
- d3=sqrt(pow((s3x-s1x),2)+pow((s3y-s1y),2));
- if(d1>=d2 && d1>=d3)
- {h=d1;
- side1=d2;
- side2=d3;
- }
- else if(d2>=d1 && d2>=d3)
- {h=d2;
- side1=d1;
- side2=d3;
- }
- else if(d3>=d2 && d3>=d1)
- {h=d3;
- side1=d1;
- side2=d2;
- }
- cout<<h<<" "<<side1<<" "<<side2<<endl;
- }
- void displaytype(double h, double side1, double side2)
- {
- side1 = double(int(side1*10.00))/10.00;
- side2 = double(int(side2*10.00))/10.00;
- h = double(int(h*10.00))/10.00;
- if(((side2*side2)+(side1*side1))>(h*h))
- {
- cout<<" "<<endl;
- cout<<"acute"<<endl;
- cout<<(side2*side2)+(side1*side1)<<" "<<(h*h)<<endl;
- }
- else if(((side1*side1)+(side2*side2))<(h*h))
- {
- cout<<" "<<endl;
- cout<<"obtuse"<<endl;
- }
- else
- {
- cout<<" "<<endl;
- cout<<"right"<<endl;
- }
- }
Add Comment
Please, Sign In to add comment