include math include iostream using namespace std float perim float k1

 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
#include <math>
#include <iostream>
using namespace std;
float perim(float k1x, float k1y, float k2x, float k2y, float k3x, float k3y) {
float ab, bc, ac, v1x, v1y, v2x, v2y, v3x, v3y;
v1x = k2x - k1x;
v1y = k2y - k1y;
v2x = k3x - k2x;
v2y = k3y - k2y;
v3x = k3x - k1x;
v3y = k3y - k1y;
ab = sqrt(pow(v1x, 2) + pow(v1y, 2));
bc = sqrt(pow(v2x, 2) + pow(v2y, 2));
ac = sqrt(pow(v3x, 2) + pow(v3y, 2));
return ab + bc + ac;
}
int main(int argc, char* argv[])
{
float k1x, k1y, k2x, k2y, k3x, k3y;
cout << "A (x) = ";
cin >> k1x;
cout << "A (y) = ";
cin >> k1y;
cout << "B (x) = ";
cin >> k2x;
cout << "B (y) = ";
cin >> k2y;
cout << "C (x) = ";
cin >> k3x;
cout << "C (y) = ";
cin >> k3y;
cout << "P = " << perim(k1x, k1y, k2x, k2y, k3x, k3y) << endl;
system("PAUSE");
return 0;
}