概要
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 実行結果
ズン
ズン
ドコ
ズン
ズン
ドコ
ドコ
ズン
ドコ
ドコ
ズン
ドコ
ズン
ズン
ドコ
ドコ
ドコ
ドコ
ドコ
ズン
ズン
ドコ
ドコ
ドコ
ドコ
ズン
ドコ
ドコ
ドコ
ドコ
ズン
ズン
ズン
ドコ
ズン
ズン
ドコ
ズン
ズン
ズン
ズン
ドコ、キヨシ
成果物
以上。