| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 872 人关注过本帖
标题:有关杨辉三角形程序的问题
只看楼主 加入收藏
klklk
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2005-4-6
收藏
 问题点数:0 回复次数:2 
有关杨辉三角形程序的问题
以下是一个杨辉三角形的程序输出是一个像直角三形的我想让它变成一个像等边三角形的杨辉三角形请问应该怎么改。 #include <stdio.h> #define N 6 main() {int i,j,a[N]N]; a[0][0]=1; printf("%4d\n",a[0][0]); for(i=1;i<N;i++) {a[i][0]=1; printf("%4d",a[i][0]); for(j=1;j<N;j++) {a[i][j]=a[i-1][j-1]+a[i-1][j]; printf(a[i][j]!=0?"%4d":'" ",a[i][j]); } printf("\n"); } }
搜索更多相关主题的帖子: 杨辉三角 
2005-06-03 12:14
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 
用链表做比较好

/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-06-03 12:39
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 

#include <stdio.h> #define N 6 main() {int i,j,a[N][N]; a[0][0]=1;

for(j=1;j<=N;j++)printf(" "); printf("%4d\n",a[0][0]);

for(i=1;i<N;i++) { for(j=1;j<=N-i;j++)printf(" ");

a[i][0]=1; printf("%4d",a[i][0]); for(j=1;j<N;j++) {a[i][j]=a[i-1][j-1]+a[i-1][j]; printf(a[i][j]?"%4d":" ",a[i][j]); } printf("\n");

}

} 等腰


/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-06-03 12:47
快速回复:有关杨辉三角形程序的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026228 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved