5
4

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 5 years have passed since last update.

ズンドコキヨシ with C++

Posted at

ズンドコキヨシまとめ - Qiita
http://qiita.com/shunsugai@github/items/971a15461de29563bf90

なかったのでC++で書いてみた。

#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <ctime>

using namespace std;

int main()
{
    vector<string> zd = {"ズン", "ドコ"};

    // ズン:10 ドコ:01 の2ビット表現とする
    unsigned long zd_check = 0;
    unsigned long zzzzd =  0x000002a9; // 10 10 10 10 01 キヨシ! 10 1010 1001  2a9

    srand(static_cast<int>(time(0)));

    do {
        zd_check = zd_check<<2 | ((rand()>>3&1)+1); // rand()>>3 は てきとう
        cout << zd[zd_check&1] << endl;
    } while ( (zd_check & zzzzd) != zzzzd );
    
    cout << "キヨシ!" << endl;
    
    return 0;
}

出力結果

ズン
ズン
ズン
ドコ
ズン
ドコ
ズン
ドコ
ドコ
ドコ
ズン
ズン
ズン
ズン
ズン
ドコ
キヨシ!
5
4
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
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?