c++输出杨辉三角(一维数组)

            #include <iostream>
            using namespace std;
            #define MAXH 17
            int main()
            {
            int i,j;
            unsigned long num[MAXH]={0};
            num[0] = 1;
            for(i = 0; i < MAXH; i++)
            {
            for(j = i; j > 0; j--)
            {
            num[j] = num[j] + num[j - 1];//A[i,j]=A[i,j-1]+A[i,j]
            cout<<num[j]<<" ";
            }
            cout<<"1"<<endl;
            }
            return 0;
            }

posted @ 2011-11-14 15:26  qiangwushuang  阅读(649)  评论(0编辑  收藏  举报