功能触发错误

时间:2019-09-04 21:03:36

标签: visual-c++ console-application

从本质上讲,我正在尝试学习C ++时开发一款临时的BlackJack游戏。我已经声明了一个数组,用于保存我的卡值,但是我有一个值,该值一次可以保存两个。每当我运行该应用程序时,我都会注意到它首先运行我的Ace()函数,但是我不希望它这样做。我想问一下随机生成器何时选择Ace()函数。

int main()
{
random_device rd;
mt19937 eng(rd());
uniform_int_distribution<> distr(0, 11);

int x = 12;
int K = 10;
int Q = 10;
int J = 10;
int Ace();

int dealer = rand() % 11 + 1;
std::vector<int> Cards = { Ace(),K,Q,J,10,9,8,7,6,5,4,3,2 };
int value;

do {
    std::vector<int> dh = { };
    do
    {
        int i = dh.size();
        dh.insert(dh.begin() + (i), Cards[distr(eng)]);

    } while (dh.size() < 2); {

        if (dh[0] + dh[1] < 21)
        {
            int ph = dh[0] + dh[1];
            string input;
            cout << dh[0] << "," << dh[1] << "\n";
            cout << "Your total is " << ph << "\n" << "Do you want to hit or stay? ";
            cin >> input;

        }
        else
        {

        }


    }


} while (Cards[distr(eng)] < 1000);
{
    puts("STOP!");
    return 0;
}

}
int Ace() {
  int x;
  cout << "You drew an Ace! " << "\n" << "Do you want to make it 11 or 1?";
  cin >> x;
  return x;
}

0 个答案:

没有答案