题解 | #蛇形矩阵#

蛇形矩阵

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")

全部评论

相关推荐

达芬骐:一个月入门,一年熟悉,三年精通,五年掌握,十年会用
点赞 评论 收藏
分享
我只是一个小白菜:我还用不惯m4,也是山猪吃不了细糠了
投递字节跳动等公司10个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务