diff options
Diffstat (limited to 'archive/q/fizzbuzz/a/313/index.html')
| -rw-r--r-- | archive/q/fizzbuzz/a/313/index.html | 196 |
1 files changed, 196 insertions, 0 deletions
diff --git a/archive/q/fizzbuzz/a/313/index.html b/archive/q/fizzbuzz/a/313/index.html new file mode 100644 index 0000000..920e609 --- /dev/null +++ b/archive/q/fizzbuzz/a/313/index.html @@ -0,0 +1,196 @@ +<!DOCTYPE html> +<html> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>問題 #1 - 回答 #313 | Albatross.PHP</title> + <link rel="stylesheet" href="../../../../assets/index.css"> + <link rel="icon" type="image/svg+xml" href="../../../../assets/favicon.svg"> + <script type="module" src="../../../../assets/index.js"></script> + </head> + <body> + <header class="container"> + <nav class="navbar"> + <a class="navbar-brand" href="../../../../index.html">Albatross.PHP</a> + </nav> + </header> + <main class="container mt-5"> + <h1 class="mb-4">問題 #1 - 回答 #313</h1> + <nav> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="../../../../index.html">問題一覧</a></li> + <li class="breadcrumb-item"><a href="../../index.html">FizzBuzz</a></li> + <li class="breadcrumb-item"><a href="../index.html">回答一覧</a></li> + <li class="breadcrumb-item active">#313</li> + </ol> + </nav> + + <h2>FizzBuzz</h2> + <p> + いわゆる「FizzBuzz」を実装してください。
+1から100までの数字について、その数が3の倍数なら「Fizz」、5の倍数なら「Buzz」、15の倍数なら「FizzBuzz」、それ以外ならその数そのものを出力してください。それぞれの出力は改行で区切ってください。 + </p> + <h2>回答 #313</h2> + <p> + zonepotage が 2024-03-09 16:48:49 に投稿 + </p> + <h2>コード</h2> + <p> + 587 byte + </p> + <pre><code class="hljs language-php"><?php
+ $f = [0, 0, 'Fizz'];
+ $b = [0, 0, 0, 0, 'Buzz'];
+
+ $i = 100;
+ $j = $i - 1;
+ c();
+
+
+ function c() {
+ global $i, $j, $k, $f, $b;
+ p();
+ print "\n";
+ array_push($f, $f[0]);
+ array_push($b, $b[0]);
+ array_shift($f);
+ array_shift($b);
+ --$j && c();
+ p();
+ print "\n";
+ exit;
+ }
+
+ function p() {
+ global $i, $j, $k, $f, $b;
+ $k = $i - $j;
+ $f[0] || $b[0] || print $k;
+ $f[0] || $b[0] ;
+ $f[0] && print $f[0];
+ $b[0] && print $b[0];
+ return;
+ }</code></pre> + <h2>実行結果</h2> + <div class="js-phper-token"> + </div> + <div class="mt-3"> + ステータス: <span class="js-aggregated-execution-status" data-answer-id="580">失敗</span> + </div> + <div class="mt-3"> + <h3>テストケース 1</h3> + <div> + ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="1272">実行時エラー</span> + </div> + <h4>標準出力</h4> + <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="1272">1 +2 +Fizz +4 +Buzz +Fizz +7 +8 +Fizz +Buzz +11 +Fizz +13 +14 +FizzBuzz +16 +17 +Fizz +19 +Buzz +Fizz +22 +23 +Fizz +Buzz +26 +Fizz +28 +29 +FizzBuzz +31 +32 +Fizz +34 +Buzz +Fizz +37 +38 +Fizz +Buzz +41 +Fizz +43 +44 +FizzBuzz +46 +47 +Fizz +49 +Buzz +Fizz +52 +53 +Fizz +Buzz +56 +Fizz +58 +59 +FizzBuzz +61 +62 +Fizz +64 +Buzz +Fizz +67 +68 +Fizz +Buzz +71 +Fizz +73 +74 +FizzBuzz +76 +77 +Fizz +79 +Buzz +Fizz +82 +83 +Fizz +Buzz +86 +Fizz +88 +89 +FizzBuzz +91 +92 +Fizz +94 +Buzz +Fizz +97 +98 +Fizz +Buzz + +</code></pre> + <h4>標準エラー出力</h4> + <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="1272"> +</code></pre> + </div> + <script type="module" src="../../../../assets/loading.js"></script> + </main> + <footer class="container text-center mt-5 mb-4"> + Albatross.PHP - PHPerKaigi 2024 + </footer> + </body> +</html> |
