蛇形矩阵

链接:https://ac.nowcoder.com/acm/problem/22231
来源:牛客网
 

题目描述

给你一个整数n,输出n∗n的蛇形矩阵。

输入描述:

输入一行,包含一个整数n

输出描述:

输出n行,每行包含n个正整数,通过空格分隔。

1<=n<=1000

示例1

输入

复制4

4

输出

复制1 2 6 7 3 5 8 13 4 9 12 14 10 11 15 16

1 2 6 7
3 5 8 13
4 9 12 14
10 11 15 16
#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
    int a[101][101],n,i,j,k,flag=1,flag1;
    cin>>n;
    k=1;i=1;j=1;
    int temp=0;
    while(k<=n*(n+1)/2)
    {
    	flag1=flag;
    	//	cout<=1)&&(j>=1))
    	{
    		//cout<

 

你可能感兴趣的:(模拟·)