public int getDistance(int[] StopStation) { Console.WriteLine("___GETDISTANT " + Service_algo.PrettyPrintArrays(StopStation)); int source_index = 0, des_index = 0; for (var i = StopStation.Length - 1; i >= 0; i--) { if (StopStation[i] == 1) { des_index = i; break; } } for (var i = 0; i < StopStation.Length; i++) { if (StopStation[i] == 1) { source_index = i; break; } } Console.WriteLine("souce_index " + source_index + " Des_index " + des_index); var result = Math.Abs(PhysicalData.distance_meter[source_index] - PhysicalData.distance_meter[des_index]); return(result); }
public (int, int) getSouceDesIndex() { Console.WriteLine("__GET SOURCE_DEST " + Service_algo.PrettyPrintArrays(StopStation)); int source_index = 0, des_index = 0; for (var i = StopStation.Length - 1; i >= 0; i--) { if (StopStation[i] == 1) { des_index = i; break; } } for (var i = 0; i < StopStation.Length; i++) { if (StopStation[i] == 1) { source_index = i; break; } } Console.WriteLine("souce_index " + source_index + " Des_index " + des_index); return(source_index, des_index); }