2 点間の距離を表示させる部分を付け加えよう。
n = 1 distance = dist[n]-dist[n-1] while n < dist.length printf("%s -- %s: %4.1f\n", stop[n], stop[n-1], distance) n += 1 end
全ての 2 点間の距離を求めることができた。 平均値より大きい距離のところだけ出すには、分岐文を加えればよい。
if distance > avg printf("%s -- %s: %4.1f[km]\n", stop[n], stop[n-1], distance) end