LoginSignup
0
0

More than 5 years have passed since last update.

Ada言語 9日目 FizzBuzz

Posted at

はじめに

if文とfor文が使えるようになったのでFizzBuzzができるようになりました。
やるしかありませんね。

ソースと結果

main.adb

with Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;

procedure main is

    counter : Integer := 0;

begin

    for counter in 1 .. 32 loop

        Ada.Integer_Text_IO.Put(counter, 1);
        Ada.Text_IO.New_Line;

        if counter mod 3 = 0 then
            Ada.Text_IO.Put_Line("Fizz");
        end if;

        if counter mod 5 = 0 then
            Ada.Text_IO.Put_Line("Buzz");
        end if;

    end loop;

end main;

実行結果 : FizzBuzzは成功しました。

最後に

Fizz!Buzz!

日記一覧へ

Ada言語を習得する日記一覧

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0