标题:杨辉三角形问题
只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-134521-1-1.html




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

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