63 lines
1006 B
C
63 lines
1006 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#define Square(x) ((x)*(x))
|
||
|
|
||
|
typedef struct Point
|
||
|
{
|
||
|
float x;
|
||
|
float y;
|
||
|
}Point;
|
||
|
|
||
|
typedef struct Circle
|
||
|
{
|
||
|
Point Center;
|
||
|
int Radius;
|
||
|
}Circle;
|
||
|
|
||
|
typedef enum result_enum
|
||
|
{
|
||
|
isInside,
|
||
|
isOutside,
|
||
|
}result_enum;
|
||
|
|
||
|
result_enum inside(Circle* c, Point* p)
|
||
|
{
|
||
|
result_enum result;
|
||
|
if(Square(c->Center.x - p->x) + Square(c->Center.y - p->y) <= Square(c->Radius))
|
||
|
{
|
||
|
result =isInside;
|
||
|
}
|
||
|
else{
|
||
|
result =isOutside;
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
int main(int argc, const char *argv[])
|
||
|
{
|
||
|
if(argc != 3)
|
||
|
{
|
||
|
printf("Wrong number of Arguments!");
|
||
|
return 1;
|
||
|
}
|
||
|
float x = atoi(argv[1]);
|
||
|
float y = atoi(argv[2]);
|
||
|
|
||
|
Point CircleCenter = {5,3};
|
||
|
Circle C = {CircleCenter, 6};
|
||
|
|
||
|
Point p;
|
||
|
p.x = x;
|
||
|
p.y = y;
|
||
|
|
||
|
if(inside(&C,&p)==isInside)
|
||
|
{
|
||
|
printf("Point (%4.2f, %4.2f) is Inside the Circle.\n", x, y);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
printf("Point (%4.2f, %4.2f) is not Inside the Circle.\n", x, y);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|