题解 | #蛇形矩阵#
蛇形矩阵
http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
int value_temp = 1;
for(int line = 0; line < n; line++) {
if(line>0) value_temp += line;
int value = value_temp;
for(int i = 0; i < n-line; i++) {
if(i>0) value += (i+1+line);
cout << value << ' ';
}
cout << endl;
}
return 0;
}