📄 package problem.cpp
字号:
// Package Problem.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int stone[]={1,8,4,3,5,2,9};
int answer[7]={0};
void package(int t,int n)
{
// if(n<0)return;
if(t==0&&n>=0)
{
for(int i=7;i>=0;i--)
{
if(answer[i]!=0)
cout<<answer[i]<<" ";
}
cout<<endl;
return;
}
// if(n==0 && ( (t<0) || (t>0) ) )
if(n>=0&&t>0)
{
answer[n-1]=stone[n-1];
package(t-answer[n-1],n-1);
answer[n-1]=0;
package(t,n-1);
}
}
void main()
{
package(10,7);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -