题解 | #蛇形矩阵#

蛇形矩阵

https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e

#include <iostream>
#include <vector>
#include <iostream>
using namespace std;

int main() {
    int n = 0;
   cin >> n;
    vector<vector<int>> res(n+1,vector<int>(n+1));
    for(int i = 1 ; i <= n ; i++){
        for(int  j = i ; j <= n ;j++){
            res[i][j] = (j+1)*j/2 -i + 1;
            cout << res[i][j] << " ";}
        cout << " "  << endl;
    }
   
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

03-29 14:19
门头沟学院 Java
你背过凌晨4点的八股文么:加油同学,人生的容错率很高,只是一个暑期罢了,后面还有很多机会!
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务