题解 | #蛇形矩阵#
蛇形矩阵
http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
#include<iostream>
#include<string>
using namespace std;
int main(){
int n;
while (cin>>n){
int beg = 1;
for (int i =1; i<=n; i++){
cout<<beg;
int tmp = beg;
for (int j = i+1; j<=n; j++){
tmp += j;
cout<<" "<<tmp;
}
cout<<endl;
beg+=i;
}
}
return 0;
}