题解 | 蛇形矩阵
蛇形矩阵
https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
#include <cstdio>
#include <iostream>
using namespace std;
int main() {//---------找规律
int n;
cin >> n;
int a = 1, pro = 1;
for (int i = 1; i <= n; i++){
cout << pro << ' ';
for (int j = i + 1; j <= n; j++){
pro += j;
cout << pro << ' ';
}
cout << endl;
a += i;
pro = a;
}
}
// 64 位输出请用 printf("%lld")
#写题解领奖励#
查看8道真题和解析