#include <iostream> using namespace std; // 看懂了不代表会做,一定要自己动手写一遍 int main(){ int n; cin >> n; int k = 1; // 观察输出的蛇形矩阵,我们会发现矩阵的每行和每列均为二级等差数列(即数列相邻项的差为等差数列) for (int i = 0; i < n; ++i){ cout << k << " "; int tmp = k; for (int j = i + 1; j < n; ++j){ tmp += j + 1; cout << tmp << " "; } cout << endl; k += i + 1; } return 0; }