Skip to content

Instantly share code, notes, and snippets.

@meki
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meki/8765229 to your computer and use it in GitHub Desktop.
Save meki/8765229 to your computer and use it in GitHub Desktop.
AOJ_0001_PHP
<?php
$hi = fopen('php://stdin', "r");
$ho = fopen('php://stdout', "w");
# 空の配列を作成
$arr = array();
# 標準入力からデータをセット
for($i = 0; $i < 10; $i++)
{
fscanf($hi, "%d", $arr[]);
}
# 降順ソート
rsort($arr);
# 出力
for($i = 0; $i < 3; $i++)
{
fwrite($ho, sprintf("%d\n", $arr[$i]));
}
fclose($ho);
fclose($hi);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment