用6个自然数组成三角形,判断语句如何写,请问

用6个自然数组成三角形,判断语句怎么写,请教
用1-6这6个自然数组成一个三角形,让这个三角形三条边的值之和相等,如图:三边的值之和都等于12,请输出所有的可能。


用6个自然数组成三角形,判断语句如何写,请问


这题是不是需要用6个循环,而且值一个比一个小?

循环这样对不对?


int a,b,c,d,e,f;
    for(a=1;a<=6;a++)
    {
for(b=1;b<=5;b++)
        {
      for(c=1;c<=4;c++)
              {
    for(d=1;d<=3;d++)
            {
 for(e=1;e<=2;e++)
         {
     for(f=1;f<=1;f++)
     {
                               这里的判断语句该怎么写?
                              }
                          }
                     }
               }
         }
    }



中间的判断语句该怎么写?请教,谢谢。

------解决方案--------------------
首先要知道你的变量代表哪里的数。其次,我们不需要这样的循环,可以减少不少的循环步骤,比如:

令最上边的数字为a,左边的数字为b,右边的数字为c,那么由于这个三角形的对称性,我们可以设
a>b>c,然后……你懂的!
------解决方案--------------------
//   0
//  1 2
// 3 4 5
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int i;
int main() {
    vector<char> P(6);
    vector<char>::iterator b,e;
    b=P.begin();
    e=P.end();
    for (i=0;i<6;i++) P[i]=i+1;
    i=0;
    do {
        if (P[0]+P[1]+P[3]==12
         && P[0]+P[2]+P[5]==12
         && P[3]+P[4]+P[5]==12) {
            printf("%d:\n",++i);
            printf("  %d\n"    ,    P[0]      );
            printf(" %d %d\n"  ,  P[1],P[2]   );
            printf("%d %d %d\n",P[3],P[4],P[5]);
        }
    } while (next_permutation(b,e));
    printf("The total: %d",i);
    return 0;
}
//1:
//  4
// 2 3
//6 1 5
//2:
//  4
// 3 2
//5 1 6
//3:
//  5
// 1 3
//6 2 4
//4:
//  5
// 3 1
//4 2 6
//5:
//  6
// 1 2
//5 3 4
//6:
//  6
// 2 1
//4 3 5
//The total: 6

------解决方案--------------------
a
b c
d e f

for a 1 to 6
for b 1 to 6
for c 1 to 6
for d 1 to 6
for e 1 to 6
for f 1 to 6
if ((abcdef互不相等)&&(sum(abd) == sum(def) == sum(acf)))

以上没有任何优化
------解决方案--------------------

#include <string>
#include <iostream>
using namespace  std;
void PrintTri(int* arr,int total,int num,int sum1,int sum2,int sum3,string res)
{
int temp; char buffer[5];

if(total==0&&sum1==sum2&&sum2==sum3)
{
cout<<(res)<<endl;
}

for(int i=0;i<total;i++){
temp=arr[0];
arr[0]=arr[i];
arr[i]=temp;
int temparr[6];
for(int j=1;j<total;j++)
temparr[j-1]=arr[j];
int tempsum1=sum1;