要求:输出矩阵
套路:找坐标i,j和元素大小的关系
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int N;
while (cin >> N,N){
for (int i = 0;i < N;i++){
for (int j = 0; j < N;j++){
int ABS = abs(i-j);
cout << 1 + ABS << " " ;
}
cout << endl;
}
cout << endl;
}
return 0;
}