All pastes #10929 Raw Edit

Mine!

public cpp v1 · immutable
#10929 ·published 2005-05-04 19:03 UTC
rendered paste body
#include <iostream>#include <math.h>using namespace std;struct point{ int number; double x; double y; double distance;};int main(void){ int n, i, ii; point *array, p, tmp; cout << "enter the # of points" << endl; cin >> n; array=new point[n]; for(i=0;i<n;i++) {  array[i].number=i;  cin >> array[i].x >> array[i].y; } cout << "enter the starting point" << endl; cin >> p.x >> p.y; for(i=0;i<n;i++)  array[i].distance=sqrt(pow(array[i].y-p.y,2)+pow(array[i].x-p.x,2)); // Bubble sort for(i=0;i<n-1;i++) {  for(ii=0;ii<n-i-1;ii++)  {   if(array[ii+1].distance < array[ii].distance)   {    tmp=array[ii];    array[ii]=array[ii+1];    array[ii+1]=tmp;   }  } } cout << "input order\tdistance\t(x,y)\n"; for(i=0;i<n;i++)  cout << array[i].number << "\t\t" << array[i].distance << "\t\t(" << array[i].x << "," << array[i].y << ")" << endl; return 0;}