也是打靶问题

abcdef0966 abcdef0966 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
一个射击运动员打靶,靶一共有10环,连开10枪打中90环的可能行有多少种?
#include <iostream>
using namespace std;


void Target(int count, int score,int turns);

static int count;

int main()
{
Target(count,90,10);
cout << count << endl;



return 0;
}

void Target(int count, int score, int turns)
{
if (score < 0 || 10 * turns < score)
return;
if (0 == turns)
{

++count;
return;

}

for (int i = 0; i < 11; i++)
{
Target(count,score-i,turns-1);
}
}


我声明的count是全局变量啊,为什么值不能改变呢
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
abcdef0966
数据结构与算法 33,027 成员 35,334 内容