zoukankan      html  css  js  c++  java
  • 猜 1-100 内的数字,范围逐渐缩小

    void guessNumber()
    {
        uniform_int_distribution<unsigned> creator1To100(1, 100);
        default_random_engine engin;
    auto answer
    = creator1To100(engin); unsigned low = 1; unsigned high = 100;
    while (true){ cout << "Guess a number: "; unsigned guess = 1; cin >> guess; if(guess == answer){ cout << "Yeah, Binggo!!!!"; return; } uniform_int_distribution<unsigned> lowBoundCreator(low, answer - 1); low = lowBoundCreator(engin); uniform_int_distribution<unsigned> highBoundCreator(answer + 1, high); high = highBoundCreator(engin); cout << "The number between the " << low << " and " << high << endl; } }
  • 相关阅读:
    Manjaro中添加gitee的公钥部署
    另类的linux系统
    mac的快捷键flykey应用
    tidb总览
    raft算法
    tidb的tidb
    tidb的tikv
    tidb的pd
    切尔诺贝利事故
    血钻
  • 原文地址:https://www.cnblogs.com/wuOverflow/p/4648821.html
Copyright © 2011-2022 走看看