1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
1 //#include "stdafx.h"
2 #include <iostream>
3 #include <cmath>
4
5 using namespace std;
6
7 //float x1, Y1, x2, y2, x3, y3; float a, b, c;
8 //the definition here has a problem during compiling
9
10 float calcDistanceP1(float , float , float , float );
11 //float calcDistanceP2(float x2, float x1, float y2, float Y1);
12 //float calcDistanceP3(float x3, float x2, float y3, float y2);
13 void welcomeMessage(){
14 cout<<"welcome to the Right Angle Triangle caculator"<<endl;
15 }
16 int main() {
17 float x1,y1,x2,y2,x3,y3;float a,b,c;
18 welcomeMessage();
19 cout << "Please Enter The First Point (x1 Y1): ";
20 cin >> x1 >> y1;
21 cout << endl;
22
23 cout << "Now Enter The Second Point (x2 y2): ";
24 cin >> x2 >> y2;
25 cout << endl;
26
27 cout << "And Finally The Third Point (x3 y3): ";
28 cin >> x3 >> y3;
29 cout << endl;
30
31 a=calcDistanceP1( x2, x1, y2, y1);
32 b=calcDistanceP1( x3, x1, y3, y1);
33 c=calcDistanceP1( x3, x2, y3, y2);
34 cout<<"a:"<<a<<" b:"<<b<<" c:"<<c<<endl;
35
36
37 return 0;
38 }
39
40 float calcDistanceP1(float x_2, float x_1, float y_2, float Y_1){
41 float distance =0;
42 distance=(float)sqrt(pow(x_2 - x_1, 2) + pow(y_2 - Y_1, 2));
43 return distance; // These three return values is where I am having trouble
44 }
45 #if 0
46 float calcDistanceP2(float x3, float x1, float y3, float y1) {
47 float b = sqrt(pow(x3- x1, 2) + pow(y3 - Y1, 2));
48 return b; // Here
49 }
50
51 float calcDistanceP3(float x3, float x2, float y3, float y2) {
52 float c = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
53 return c; //Here
54 }
55 #endif
|