#include<iostream>
#include<iomanip>
using namespace std;
void main(){
int i,j,a[100][100],n,k;
cout<<"input the width of the matrix:";
cin>>n;
k=1;
for(i=1;i<=n;i++){
for(j=1;j<=n+1-i;j++){
a[i-1+j][j]=k;
k=k+1;
}
}
for(i=1;i<=n;i++){
for(j=1;j<=i;j++){
cout<<setw(4)<<a[i][j]<<" ";
}
cout<<endl;
}
return ;
}
c++实现特殊数字矩阵
最新推荐文章于 2024-05-17 21:03:26 发布