I have to do my homework for passing the course :)
The question is that;
Firstly the starting point is (x1,y1) we get these values from user and
we get a lot of two dimensional points from user.If a point is far away from the center point of the points, it is discarded and displayed as a outlier point. Otherwise a new center point is calculated.
The question's
Inputs:
• Delta( Δ ) distance for outliers
• Get two dimensional points (x,y)
• point (0,0) ends application
Outputs:
• Display center point (x,y) at each new point.
• If a point (x,y) is found to be outlier give a message
should be like that.I developed such a program but it doesnt work truely.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double findDelta(int x1,int x2,int y1,int y2); //function prototype for distance
double findNewCenter(int x1,int x2,int y1,int y2); //function prototype for new center
int main(int argc, char *argv[])
{
double distance; // the distance between two points
int x1,x2,y1,y2; // these are variables for dimensionals
int tempx1,tempy1;
printf("Enter the x point\n"); // we specify first point
scanf("%d",&x1);
printf("Enter the y point\n"); // we specify second point
scanf("%d",&y1);
do{
printf("Enter another x point\n"); // getting new x point
scanf("%d",&x2);
printf("Enter another y point\n"); // getting new y point
scanf("%d",&y2);
findNewCenter(x1,x2,y1,y2); // function for finding new center
findDelta(x1,x2,y1,y2); // function for finding new distance
}while(x1!=0 && x2!=0);
system("PAUSE");
return 0;
}
double findDelta(int x1,int x2,int y1,int y2)
{
double result,pow1,pow2; // result is distance
pow1=pow(x2,2)-pow(x1,2); // pow1 is first points' powers
pow2=pow(y2,2)-pow(y1,2); // pow2 is second points' powers
result=sqrt(abs(pow1)+abs(pow2));
printf("Distance=%f\n",result); // it shows the distance
}
double findNewCenter(int x1,int x2,int y1,int y2)
{
double cx,cy; // center points' variables
cx=(x1+x2)/2; // finding center's x axis
cy=(y1+y2)/2; // finding center's y axis
printf("New center point is %f %f\n",cx,cy); //it display the new center
}
I need some ideas for solving this problem.im waiting for your helps :)