I would like to know, how to find consecutive nearest/closest points of the given random points. I have found the random points but not able to find the consecutive nearest points. The number of random points is user input. I have to find consecutive points for random points more than 4.
void main() {
int n,c;
double rand_minx,rand_maxx, rand_miny, rand_maxy;
double x[100],y[100];
printf("enter the number of points required ");
scanf("%d",&n);
printf("enter the minimum number of x ");
scanf("%lf",&rand_minx);
printf("enter the maximum number of x ");
scanf("%lf",&rand_maxx);
printf("enter the minimum number of y ");
scanf("%lf",&rand_miny);
printf("enter the maximum number of y ");
scanf("%lf",&rand_maxy);
double range1=(rand_maxx-rand_minx);
double range2=(rand_maxy-rand_miny);
printf("Coordinates of (x,y)\n");
for(c=0;c<n;c++){
x[c] = rand_minx+(range1*rand()/RAND_MAX);
y[c] = rand_miny+(range2*rand()/RAND_MAX);
printf("(%3.2lf,%3.2lf)\n", x[c],y[c]);
}
Aucun commentaire:
Enregistrer un commentaire