Created
July 14, 2013 04:21
-
-
Save Ryokuchaneko/5993205 to your computer and use it in GitHub Desktop.
誰がどの便でLGAにやってくるかを$sで表現する。各数字はその日の何便目に乗るか。そして、Seymourの行き・帰り・Frannyの行き・帰り・・・の順に並んでいる。この数列から各人の旅程の情報を出力する関数を定義する(printschedule)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$s = array(1,4,3,2,7,3,6,3,2,4,5,3); | |
function printschedule($r, $people, $flights, $destination) { | |
$d = count($r)/2; | |
for($i = 0; $i < $d; $i++){ | |
$name = $people[$i][0]; | |
$origin = $people[$i][1]; | |
$out = $flights[$origin][$destination][$r[($i*2)]]; | |
$ret = $flights[$destination][$origin][$r[($i*2+1)]]; | |
echo sprintf("%10s%10s %5s-%5s $%3s %5s-%5s $%3s" . PHP_EOL, $name, $origin, $out[0], $out[1], $out[2], $ret[0], $ret[1], $ret[2]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment