| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 591 人关注过本帖
标题:杨辉三角形问题
只看楼主 加入收藏
woshiyfk
Rank: 1
等 级:新手上路
帖 子:74
专家分:0
注 册:2005-3-2
收藏
 问题点数:0 回复次数:1 
杨辉三角形问题
#include <iostream.h>
class yanghui{
int *y[10];
public:
yanghui()
{int i,j;
for(i=0; i<10; i++)
{y[i] = new int[sizeof(int) * (i+1)];
for(j=0; j<=i; j++)
{if(j=0 || i==j)
*(y[i]+j)=1;
else
*(y[i]+j) = *(y[i-1]+(j-1)) + *(y[i-1]+j);
}
}
void showyanghui()
{int i,j;
for(i=0; i<10; i++)
{for(j=0; j<=i; j++)
{cout << *(y[i]+j);}
cout << endl;}
}
};
main()
{yanghui a;
a.showyanghui();
}


我自己看了一下没发现什么问题。出现错误提示:
yanghui.cpp
C:\yanghui.cpp(27) : warning C4183: 'main': member function definition looks like a ctor, but name does not match enclosing class
C:\yanghui.cpp(28) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
搜索更多相关主题的帖子: 杨辉三角 
2007-04-24 15:37
gdmzzwf
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-4-23
收藏
得分:0 
main前好像要加一个void.......
或用int 后面加个return 0;
试试吧...
2007-04-24 22:34
快速回复:杨辉三角形问题
数据加载中...
 
   



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

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