当前位置:网站首页>Serpentine matrix
Serpentine matrix
2022-07-05 04:11:00 【Learning KL & TK】

#include"bits/stdc++.h"
using namespace std;
int s[105][105];
int n;
void init(){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
printf("%d ",s[i][j]);
cout << endl;
}
}
int main()
{
cin >> n;
int ans = 1;
int i = 0 , j = 0;
s[0][0]=ans++;
while(ans < n*n){
// Judge whether it is horizontal or vertical
if(j < n-1)
j++;
else
i++;
s[i][j] = ans++;
// The lower left
while(j>0 && i < n-1){
j--;i++;
s[i][j] = ans++;
}
// Judge whether it is horizontal or vertical
if(i < n-1)
i++;
else
j++;
s[i][j] = ans++;
// The upper right
while(i>0 && j<n-1){
j++;i--;
s[i][j] = ans++;
}
}
init();
return 0;
}边栏推荐
- Test d'automatisation de l'interface utilisateur télécharger manuellement le pilote du navigateur à partir de maintenant
- Threejs rendering obj+mtl model source code, 3D factory model
- Rome chain analysis
- 测试开发是什么?为什么现在那么多公司都要招聘测试开发?
- 网络安全-记录web漏洞修复
- 【虚幻引擎UE】运行和启动的区别,常见问题分析
- The order of LDS links
- How to use jedis of redis
- [charging station]_ Secular wisdom_ Philosophical wisdom _
- JVM garbage collection
猜你喜欢

Threejs Internet of things, 3D visualization of factory

阿里云ECS使用cloudfs4oss挂载OSS

陇原战“疫“2021网络安全大赛 Web EasyJaba

Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
![[brush questions] BFS topic selection](/img/24/7ec68ef60f94f7b366054824223709.png)
[brush questions] BFS topic selection

【虚幻引擎UE】运行和启动的区别,常见问题分析

ActiveReportsJS 3.1 VS ActiveReportsJS 3.0

Enterprise level: spire Office for . NET:Platinum|7.7. x

【虛幻引擎UE】實現UE5像素流部署僅需六步操作少走彎路!(4.26和4.27原理類似)

基于TCP的移动端IM即时通讯开发仍然需要心跳保活
随机推荐
Threejs implements labels and displays labels with custom styles
EasyCVR平台出现WebRTC协议视频播放不了是什么原因?
[understand series after reading] 6000 words teach you to realize interface automation from 0 to 1
面试字节,过关斩将直接干到 3 面,结果找了个架构师来吊打我?
Realize the attention function of the article in the applet
C language course setting: cinema ticket selling management system
【刷题】BFS题目精选
Learning MVVM notes (1)
open graph协议
美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
【看完就懂系列】一文6000字教你从0到1实现接口自动化
陇原战“疫“2021网络安全大赛 Web EasyJaba
Containerd series - what is containerd?
A real day for Beijing programmers!!!!!
[charging station]_ Secular wisdom_ Philosophical wisdom _
[untitled]
Use threejs to create geometry and add materials, lights, shadows, animations, and axes
About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture
Looking back on 2021, looking forward to 2022 | a year between CSDN and me
[moteur illusoire UE] il ne faut que six étapes pour réaliser le déploiement du flux de pixels ue5 et éviter les détours! (4.26 et 4.27 principes similaires)