no message
This commit is contained in:
16
Question08-Function/Ex01.php
Normal file
16
Question08-Function/Ex01.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* 以下の仕様で関数が作成されています
|
||||
*
|
||||
* 関数名 :number
|
||||
* 引数 :なし
|
||||
*
|
||||
* 100を返すメソッド
|
||||
*/
|
||||
function number()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
// TODO: 変数receiveを宣言し、関数numberを実行した結果を代入してください
|
||||
// TODO: 変数receiveを出力してください
|
||||
21
Question08-Function/Ex02.php
Normal file
21
Question08-Function/Ex02.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* 以下の仕様で関数が作成されています
|
||||
*
|
||||
* 関数名 :average
|
||||
* 引数 :x, y
|
||||
*
|
||||
* 引数で渡された2つの平均値を返す関数
|
||||
*/
|
||||
function average($x, $y)
|
||||
{
|
||||
$result = '平均は:' . (($x + $y) / 2);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$x = 100;
|
||||
$y = 50;
|
||||
|
||||
// TODO: 変数receiveを宣言して、average関数を(変数x, 変数y)で呼び出した結果を代入してください
|
||||
|
||||
// TODO: 変数receiveを出力してください
|
||||
22
Question08-Function/Ex03.php
Normal file
22
Question08-Function/Ex03.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/* TODO:
|
||||
* 以下の仕様で関数を作成してください
|
||||
*
|
||||
* 関数名 :isEvenNumber
|
||||
* 引数 :x
|
||||
*
|
||||
* 引数で渡された内容が偶数ならtrue、奇数ならfalseを返す関数
|
||||
*/
|
||||
|
||||
|
||||
// TODO: 0~100のランダムな値を取得して、変数numberに代入してください
|
||||
|
||||
// TODO: 変数resultを宣言し、関数isEvenNumberを(変数number)で呼び出した結果を代入してください
|
||||
|
||||
|
||||
// 取得した値が偶数か奇数か判定します
|
||||
if ($result) {
|
||||
echo '偶数です';
|
||||
} else {
|
||||
echo '奇数です';
|
||||
}
|
||||
13
Question08-Function/Ex04.php
Normal file
13
Question08-Function/Ex04.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/* TODO:
|
||||
* 以下の仕様で関数を作成してください
|
||||
*
|
||||
* 関数名 :convertMessage
|
||||
* 引数 :str
|
||||
*
|
||||
* 引数で渡された値の前後に 「 」 を付与して出力する関数("「"と引数と"」"の連結)
|
||||
*/
|
||||
|
||||
$message = 'Hello, world!';
|
||||
|
||||
// TODO: 関数convertMessageを(変数messageを引数に)で呼び出してください
|
||||
23
Question08-Function/Ex05.php
Normal file
23
Question08-Function/Ex05.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/* TODO:
|
||||
* 以下の仕様で関数を作成してください
|
||||
*
|
||||
* 関数名 :quadrangle
|
||||
* 引数 :width, height
|
||||
*
|
||||
* 引数で渡された横の長さ(width)と縦の長さ(height)から、四角形の面積を返す関数
|
||||
*/
|
||||
|
||||
|
||||
/* TODO:
|
||||
* 以下の仕様で関数を作成してください
|
||||
*
|
||||
* 関数名 :triangle
|
||||
* 引数 :width, height
|
||||
*
|
||||
* 引数で渡された横の長さ(width)と縦の長さ(height)から、三角形の面積を返す関数
|
||||
*/
|
||||
|
||||
|
||||
// TODO:
|
||||
// 変数choiceの中が、1であれば四角形の面積を算出するメソッドを、2であれば三角形の面積を算出するメソッドを呼び出してください
|
||||
5
Question08-Function/Ex06.php
Normal file
5
Question08-Function/Ex06.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/* TODO:
|
||||
* 入力された西暦がうるう年かどうかを判定する関数を作成してください
|
||||
* 関数名、引数は自由に設定してください
|
||||
*/
|
||||
5
Question08-Function/Ex07.php
Normal file
5
Question08-Function/Ex07.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/* TODO:
|
||||
* 2~n《入力された数》までの素数を評価する関数を作成し、結果を出力してください
|
||||
* 関数名、引数は自由に設定してください
|
||||
*/
|
||||
155
Question08-Function/index.html
Normal file
155
Question08-Function/index.html
Normal file
@@ -0,0 +1,155 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>PTra08スタートページ</title>
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="../common/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
PTra08-Function <small>関数</small>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="panel-group" id="accordion">
|
||||
<!-- ================== PTra08-01 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex01.php" target="_blank">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
|
||||
Ex01</a> <small>関数の呼び出し</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra08-02 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex02.php" target="_blank">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Ex02</a>
|
||||
<small>関数の引数利用</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra08-03 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex03.php" target="_blank">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Ex03</a>
|
||||
<small>関数の作成</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra08-04 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex04.php" target="_blank">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Ex04</a>
|
||||
<small>戻り値の設定</small>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ================== PTra08-05 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Ex05</a>
|
||||
<small>三角形・四角形の面積算出関数</small>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapse3" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="Ex05.php" target="_blank" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="first">図形</label>
|
||||
<select name="vote">
|
||||
<option value="1">四角形</option>
|
||||
<option value="2">三角形</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="number">縦</label>
|
||||
<input type="number" class="form-control" name="height" placeholder="数値を入力してください">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="number">横</label>
|
||||
<input type="number" class="form-control" name="width" placeholder="数値を入力してください">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Ex05</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ================== PTra08-06 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Ex06</a>
|
||||
<small>うるう年の判定関数</small>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapse2" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="Ex06.php" target="_blank" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="input">西暦</label>
|
||||
<input type="number" class="form-control" name="input" placeholder="西暦を入力してください">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Ex06</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ================== PTra08-07 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapse7">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Ex07</a>
|
||||
<small>素数判定</small>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapse7" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="Ex07.php" target="_blank" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="number">最大値</label>
|
||||
<input type="number" class="form-control" name="number" placeholder="数値を入力してください">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Ex07</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="../common/js/jquery-3.2.1.min.js"></script>
|
||||
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="../common/js/bootstrap.min"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user