创建飞镖游戏并出现两个错误
too few argurments in function call
和
game, identifier not found
我正在尝试为一项任务创建一个游戏,该游戏将使两名玩家“joe 和 sid”从 301 玩飞镖,没有双打,只有公牛和 21 个数组中的数字,非常感谢解决问题的任何帮助,下面的代码有四个主要功能,每个功能都会降低分数,首先是 50 分(公牛),然后是 20 分,然后是单打,两个玩家都必须以公牛结束,当分数达到 50 时,任何不是公牛的分数都会被丢弃.
下面是我的代码,任何帮助将不胜感激。
#include <iostream>
using namespace std;
int dartScores[] = {20, 1, 18, 4, 13, 6, 10, 15, 2, 17, 3, 19, 7, 16, 8, 11, 14, 9, 12, 5, 20};
void makeThrow( int &score );
int main ()
{
int joeScore = 301;
int sidScore = 301;
for (int i = 0; i< 1000;i++){
while( joeScore > 0 || sidScore > 0 )
{
//do a throw
game( joeScore);
game( sidScore);
}
// remember to reset the score value
}
}
void makeThrow_50( int &score, int acc )
{
if ( rand()%100 < acc )
{
score -= 50;
}
else
{
//select a random
int missedScore = dartScores[ rand()%20 ];
// Only reduce score when thrown score is less than remaining score
if (missedScore > score)
{
// Valid dart, take from score
score -= missedScore;
}
else
{
// Invalid throw - BUST
//cout << " BUST ";
}
//if (score <0) score=0;
}
}
void makeThrow_20( int &score, int acc )
{
if ( rand()%100 < acc )
{
score -= 20;
}
else
{
//select a random
int missedScore = dartScores[ rand()%20 ];
// Only reduce score when thrown score is less than remaining score
if (missedScore > score)
{
// Valid dart, take from score
score -= missedScore;
}
else
{
// Invalid throw - BUST
//cout << " BUST ";
}
//if (score <0) score=0;
}
}
void makeThrow_Single( int &score, int acc )
{
if ( rand()%100 < acc )
{
score -= 1;
}
else
{
//select a random
int missedScore = dartScores[ rand()%20 ];
// Only reduce score when thrown score is less than remaining score
if (missedScore > score)
{
// Valid dart, take from score
score -= missedScore;
}
else
{
// Invalid throw - BUST
//cout << " BUST ";
}
//if (score <0) score=0;
}
}
void makeThrow_bull( int &score, int acc )
{
if ( rand()%100 < acc )
{
score -= 50;
}
else
{
//select a random
int missedScore = dartScores[ rand()%20 ];
// Only reduce score when thrown score is less than remaining score
if (missedScore > score)
{
// Valid dart, take from score
score -= missedScore;
}
else
{
// Invalid throw - BUST
//cout << " BUST ";
}
//if (score <0) score=0;
}
}
int game(int& score, int acc) {
if (score >= 100)
makeThrow_50(score, acc);
else if (score >= 70)
makeThrow_20(score, 80);
else if (score >= 51)
makeThrow_Single(score, 80);
else
makeThrow_bull(score, 80);
}