我无法在 c++ 中调用布尔函数(已关闭)

I can`t call the bool function in c++ (closed)

本文关键字:函数 布尔 调用 c++      更新时间:2023-10-16

嘿伙计们请帮帮我,我已经尝试在我的主函数中调用我的布尔函数,但它甚至不会显示程序的第一个分支,编译器终止程序这是我的代码

#include <iostream>
using namespace std;
bool puzzle(int size, int array[], int start)
{
cout <<"how many blocks you want for the puzzle? n";
cin >> size;
for (int i = 0; i < size; i++)
{
cout << "enter your numbers in order for the blocks:n";
cin >> array[i];
if (array[0] > size) { return false; };
if (array[0] == size) { return true; };
}
}
int main()
{
puzzle;
return 0;
}


您的函数具有参数,因此您需要调用它们才能使其工作。在这种情况下(示例(:

int size = 5;
int array[5];
int start = 0;
puzzle(size, array, start);