C语言网题目 1097: 蛇行矩阵

#include<iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int low=1,up; 
	for(int i = 0;i < N;i ++)
	{
		low += i;	
		up = low;		
		cout << low;
		printf(" ");
		for(int j = i + 1;j < N;j ++)	
		{
			up += j + 1;
			cout << up;
			printf(" ");
		} 
		cout << endl;
	}
	cout << endl;
} 

猜你喜欢

转载自blog.csdn.net/m0_57214074/article/details/123219149