62,567
社区成员




#include "stdio.h"
#define MAX_NUM 100
#define DEQUAL(a,b) (fabs((a)-(b)) < 1e-6)
//输入数组
double numbers[MAX_NUM];
//输入数组大小
int size;
//第i个数起到末尾的和
double sum[MAX_NUM];
//第i位的数字是否选择上
int flag[MAX_NUM];
//数字的和
double total;
//当前累加的和
double currentSum;
//输入初始化操作
void Input()
{
}
//根据flag数组输出选择上的数
void Output()
{
}
void DFS(int depth)
{
if(depth == size || currentSum+sum[depth] < total)return;
if(DEQUAL(currentSum+numbers[depth],total))
{
flag[depth] = 1;
Output();
flag[depth] = 0;
}
else if(currentSum+numbers[depth] < total)
{
currentSum += numbers[depth];
flag[depth] = 1;
DFS(depth+1);
flag[depth] = 0;
currentSum -= numbers[depth];
}
DFS(depth+1);
}
int main()
{
return 0;
}