-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrhombus_check.cxx
More file actions
55 lines (41 loc) · 832 Bytes
/
rhombus_check.cxx
File metadata and controls
55 lines (41 loc) · 832 Bytes
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
// WARNING: NOT WORKING CODE!!!
#include <iostream>
#include <cmath>
using namespace std;
struct rhombus
{
double a;
double b;
};
struct point
{
double x;
double y;
};
#define square(x) ((x)*(x))
double distance(point a, point b)
{
return sqrt(square(b.x-a.x)+square(b.y-a.y));
}
#define MAX_POINTS 4
bool is_rhombus(point points[MAX_POINTS])
{
double distances[6];
int k = 0;
for (int i = 0; i < MAX_POINTS - 1; i++)
{
for (int j = i+1; j < MAX_POINTS; j++)
{
distances[k++] = distance(points[i], points[j]);
}
}
for (k = 0; k < 6; k++)
cout << distances[k] << endl;
return false;
}
int main() {
point points[4] = {{-2,-1},{-7,9},{4,7},{9,-3}};
is_rhombus(points);
cout<<"rhombus: " << endl;
return 0;
}