将1,2,3,…,9共9个数排成下列的三角形(用C++编程)

[复制链接]
查看11 | 回复0 | 2011-8-26 01:59:19 | 显示全部楼层 |阅读模式
将1,2,…,9共9个数排成下列形态的三角形。

a

b
c

d
e

f
g
h
i

其中:a~i分别表示1,2,…,9中的一个数字,并要求同时满足下列条件:

(1)a<fusing namespace std;int main(){int p;int a,b,c,d,e,f,g,h,i;int count=0;//单边理论最大值为6+7+8+9=30for(p=1;p<=30;p++){for(a=1;a<=9;a++){for (f=a+1;f<=9;f++){for (i=f+1;i<=...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行