📄 三角数字问题.cpp
字号:
#include <iostream>
#include <iomanip.h>
#include <stdlib.h>
using namespace std;
//枚举法
int main(int argc, char *argv[])
{
int a,b,c,d,e,f;
for(a=1;a<=6;a++)
{
for(b=1;b<=6;b++)
{
if(a==b) continue;
for(c=1;c<=6;c++)
{
if(a==c ||b==c) continue;
for(d=1;d<=6;d++)
{
if(d==a ||d==b ||d==c) continue;
for(e=1;e<=6;e++)
{
if(e==a||e==b||e==c||e==d) continue;
f=21-(a+b+c+d+e);
if(a+b+c==c+d+e && a+b+c==e+f+a)
{
cout<<"**********************"<<endl
<<setw(6)<<a<<endl
<<setw(4)<<b<<setw(4)<<f<<endl
<<setw(2)<<c<<setw(4)<<d<<setw(4)<<e<<endl;
system("pause");
}
}
}
}
}
}
cout<<"**********************"<<endl;
system("PAUSE");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -