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 58 59 60 61 62 63
|
#include <stdio.h>
#include <stdbool.h>
//verifying point validity
int main(void)
{
int x1, y1, x2, y2, x3, y3, x4, y4;
printf("Enter point #1:\n");
if (scanf("%d%d", &x1,&y1)==2)
{
goto two;
}
else
{
printf("Invalid Entry\n");
}
two:
printf("Enter point #2:\n");
if (scanf("%d%d", &x2,&y2)==2)
{
goto three;
}
else
{
printf("Invalid Entry\n");
}
three:
printf("Enter point #3:\n");
if (scanf("%d%d", &x3,&y3)==2)
{
goto four;
}
else
{
printf("Invalid Entry\n");
}
four:
printf("Enter point #4:\n");
if (scanf("%d%d", &x4,&y4)==2)
{
goto next;
}
else
{
printf("Invalid Entry\n");
}
next:
}
//function for verifying rectangle
static bool IsRectangle(int x1, int y1, int x2, int y2,
int x3, int y3, int x4, int y4)
{
x2 -= x1; x3 -= x1; x4 -= x1; y2 -= y1; y3 -= y1; y4 -= y1;
return
(x2 + x3 == x4 && y2 + y3 == y4 && x2 * x3 == -y2 * y3) ||
(x2 + x4 == x3 && y2 + y4 == y3 && x2 * x4 == -y2 * y4) ||
(x3 + x4 == x2 && y3 + y4 == y2 && x3 * x4 == -y3 * y4);
}
|