首页 > 其他 > 详细

蓝桥杯训练 蛇形矩阵 模拟

时间:2019-03-12 19:58:20      阅读:213      评论:0      收藏:0      [点我收藏+]

题目链接http://www.dotcpp.com/oj/problem1097.html

 

 

ac代码:

技术分享图片
#include<iostream>
using namespace std;

int n;
int a[110][110];
int main()
{
    while (cin >> n){
        int sum = 0;
        int tot = n;
        int t = 1;
        while (tot--){
            
                for (int i = sum; i >=0; i--)
                    a[i][sum - i] = t++;

            sum++;
        }
        //输出
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n - i; j++){
                if (j == n - i - 1)
                    cout << a[i][j];
                else 
                    cout << a[i][j] <<  ;
            }
            cout << endl;
        }
    }
    return 0;
}
View Code

 

蓝桥杯训练 蛇形矩阵 模拟

原文:https://www.cnblogs.com/looeyWei/p/10519145.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!