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
<?php | |
//------------------------------------ | |
// 定数 | |
//------------------------------------ | |
// 保存するファイル | |
define('FILE', 'data.txt'); | |
//------------------------------------ | |
// メイン処理 | |
//------------------------------------ |
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
<?php | |
$tarou = new User('太郎'); | |
$tarou->addExp(300); | |
// 現在のレベルを表示 ("太郎 Lv.4"と表示される) | |
printf("%s Lv.%d\n" | |
, $tarou->name | |
, $tarou->getLevel()); | |
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
<?php | |
//------------------------------------ | |
// 定数 | |
//------------------------------------ | |
define('LIST_NAME', 0); // MONSTER_LIST配列の「名前」の場所 | |
define('LIST_AREA', 1); // MONSTER_LIST配列の「出現場所」の場所 | |
define('LIST_LV', 2); // MONSTER_LIST配列の「レベル」の場所 | |
define('LIST_HP', 3); // MONSTER_LIST配列の「HP」の場所 | |
//------------------------------------ |
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
<?php | |
// テトリス盤 | |
// 0:空白 1:ブロック | |
$TETRIS_BOARD = [ | |
[0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 1], | |
[0, 0, 1, 0, 0, 1], | |
[0, 1, 1, 0, 0, 1], |
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
<?php | |
// オセロ盤のデータを入れる配列 | |
$OTHELLO_BOARD = [ | |
[0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 2, 0, 0], | |
[0, 0, 0, 1, 2, 1, 0, 0], | |
[0, 0, 1, 1, 2, 0, 0, 0], | |
[0, 0, 0, 0, 2, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0], |
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
<?php | |
// クエスト結果の一覧 | |
$questResult = [ | |
// ユーザーID, 討伐モンスター数, 獲得したゲーム内マネー | |
['u001', 5, 800], | |
['u002', 4, 1200], | |
['u003', 10, 900], | |
['u004', 1, 500], | |
['u005', 3, 2000] | |
]; |
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
<?php | |
$min = getMin([18, 15, 30, 17, 25]); | |
echo $min; // 15と表示される | |
/** | |
* 配列から最小値を返却する | |
*/ | |
function getMin($items){ | |
// ★ここを回答する |
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
<?php | |
$items = [18, 15, 30, 17, 25]; | |
$max = $items[0]; | |
// 一番大きな値を探す | |
for($i=1; $i<count($items); $i++){ | |
// ★ここを回答する | |
} | |
// 結果を表示 |
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
<?php | |
$items = [1, 5, 10, 12, 25]; | |
for($i=0; $i<count($items); $i++){ | |
// ※ここを回答する※ | |
} |
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
<?php | |
$items = [18, 15, 17, 25, 30]; | |
$total = 0; | |
// ※ここを回答する※ | |
echo $total; // 105と表示される | |