斜三角矩阵的生成

/* 标准文档模板 */

#include "Stdio.h"
#define NUM 5

    int col,row;
    int array[NUM][NUM];
void print()
{
    int i;
    for(row=0;row<=NUM;row++)
    {
        for(col=0;col<=NUM;col++)
        printf(" %2d ",array[row][col]) ;
        printf("/n");
    }
}
int main(void)
{
    int n=0 ;
    for(col=0;col<=NUM;col++)
    {
        for(row=NUM;row>=col;row--)
        {
            n++;
            array[row][col]=n;
        }
    }
    print();
    getch();
  return 0;
}

你可能感兴趣的:(斜三角矩阵的生成)