I need help with arrays

Hi,

int[] distances={0,0,0};

void doHomework() {
   int[] sdc = cities[8]; // Santiago de Compostela.

   for(int i=0;i<cities.length;i++) {
     if (i==8) continue; // not really required but ... :)
     int[] other=cities[i];
     int d = floor(dist(sdc[0], sdc[1],other[0], other[1]));
     if(d > distances[2]) { // check if currently stored is nearer
       distances[0] = other[0]; // store x of farest
       distances[1] = other[1]; // store y of farest
       distances[2] = d; // store farest distance
     }
   }
   // After finished distances contains the farest
}

Cheers
— mnse

PS: syntax not testes … Typed offline on mobile :slight_smile:

PPS: and please check your inital posted code … at least the syntax …

1 Like