跳到正文

休闲·娱乐

数数

xwx123456约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年2月28日
收录
2026年2月28日
更新
2026年11月14日
篇幅
约 1 分钟
获赞
1

版本

  1. v2当前
  2. v1
C++
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
int n,len;
int a[N],b[N][N];
mt19937 Rand(time(0));
signed main() {
	cin>>n;
	for(int i=1; i<=n*n; i++)a[i]=i;
	shuffle(a+1,a+n*n+1,Rand);
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++)b[i][j]=a[++len];
	}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			cout<<b[i][j]<<' ';
			if(b[i][j]<10)cout<<' ';
		}
		cout<<endl;
	}
	auto start = chrono::steady_clock::now();
	cin>>n;
	auto now = chrono::steady_clock::now();
	chrono::duration<double> elapsed = now - start;
	cout<<elapsed.count();
	return 0;
}
原文
存档评论1 条抓取于