写出c语言代码:题目描述输入整数N输出相应方阵。输入一个整数N。 0 n 10 输出一个方阵每个数字的场宽为3。样例输入5样例输出 5 4 3 2 1 5 4 3 2 2 5 4 3 3 3 5 4 4 4 4 5 5 5 5 5
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[10][10];
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
{
if(i == 0)
{
a[i][j] = n-j;
}
else
{
a[i][j] = a[i-1][j]<n-i?a[i-1][j]:n-i;
}
printf("%3d", a[i][j]);
}
printf("\n");
}
return 0;
}
原文地址: https://www.cveoy.top/t/topic/ffuM 著作权归作者所有。请勿转载和采集!