# I need help with arrays

**URL:** <https://discourse.processing.org/t/i-need-help-with-arrays/37381>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [June 7, 2022, 11:47am UTC](https://discourse.processing.org/t/i-need-help-with-arrays/37381 "2022-06-07T11:47:51Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [June 7, 2022, 3:59pm UTC](https://discourse.processing.org/t/i-need-help-with-arrays/37381/5 "2022-06-07T15:59:56Z")

</div>

Hi,

```auto
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 🙂

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

---

_[View the full topic](https://discourse.processing.org/t/i-need-help-with-arrays/37381)._
