0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AI Programmerの作法 その12

Last updated at Posted at 2022-10-06

概要

AI Programmerの作法、調べてみた。
zundokoやってみた。

投入したソースコード

  • C++
  • ランダムにズンとドコを表示し、ズンが4回続いたら、「ドコ、キヨシ」を表示する。

実行結果

ランダムにズンとドコを表示し、ズンが4回続いたら、「ドコ、キヨシ」を表示する。

#include <iostream>
#include <random>
#include <string>

int main() {
    std::random_device rd;
    std::mt19937 mt(rd());
    std::uniform_int_distribution<int> dist(0, 1);

    int count = 0;
    while (count < 4)
    {
        if (dist(mt) == 0)
        {
            std::cout << "ズン" << std::endl;
            count++;
        }
        else
        {
            std::cout << "ドコ" << std::endl;
            count = 0;
        }
    }

    std::cout << "ドコ、キヨシ" << std::endl;

    return 0;
}




paiza.io 実行結果

ズン
ズン
ドコ
ズン
ズン
ドコ
ドコ
ズン
ドコ
ドコ
ズン
ドコ
ズン
ズン
ドコ
ドコ
ドコ
ドコ
ドコ
ズン
ズン
ドコ
ドコ
ドコ
ドコ
ズン
ドコ
ドコ
ドコ
ドコ
ズン
ズン
ズン
ドコ
ズン
ズン
ドコ
ズン
ズン
ズン
ズン
ドコ、キヨシ

成果物

以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?