打表+找规律+模拟
蛇形矩阵
http://www.nowcoder.com/questionTerminal/649b210ef44446e3b1cd1be6fa4cab5e
#include<bits/stdc++.h> using namespace std; int solve[101][101]; void init() { int tag=1; while( tag<=5050 ) { for( int loop=1; loop<=100; ++loop ) { int cow=loop; for(int row=1; row<=loop; ++row, --cow) { solve[cow][row]=tag; ++tag; } } } } int main() { init(); int n; while( ~scanf("%d",&n) ) { int loop=n; for(int cow=1; cow<=n; ++cow ) { for(int row=1; row<=loop; ++row ) { printf("%d%c", solve[cow][row], (row!=loop)? ' ' : '\n'); } loop--; } } return 0; }