news 2026/4/3 4:42:06

东方博宜二维数组找规律题目

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
东方博宜二维数组找规律题目

对角线

1190. 对角线I

#include<bits/stdc++.h> using namespace std; int a[105][105]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==j){ a[i][j]=1; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(3)<<a[i][j]; }if(i==n){ break; }else{ cout<<endl; } } return 0; }

1191. 对角线II

#include<bits/stdc++.h> using namespace std; int a[105][105]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i+j==n+1){ a[i][j]=1; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(3)<<a[i][j]; } cout<<endl; } return 0; }

数字走向

1184. 数字走向I

#include<bits/stdc++.h> using namespace std; int a[105][105]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(j==1){ a[i][j]=a[i-1][n]+j; continue; } a[i][j]=a[i][j-1]+1; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(3)<<a[i][j]; if(j==n)cout<<endl; } } return 0; }

1185. 数字走向II

#include<bits/stdc++.h> using namespace std; int a[105][105]; int main(){ int n; cin>>n; int k=1; for(int i=n;i>=1;i--){ for(int j=1;j<=n;j++){ a[i][j]=k; k++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(3)<<a[i][j]; }cout<<endl; } return 0; }

1186. 数字走向III

#include <iostream> #include <iomanip> using namespace std; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cout << setw(3) << i + (j - 1) * n; } cout << endl; } return 0; }

1187. 数字走向IV

#include<bits/stdc++.h> using namespace std; int a[11][11]; int main(){ int n,sum=1; cin>>n; for(int i=n;i>=1;i--){ for(int j=1;j<=n;j++){ a[j][i]=sum; sum++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(3)<<a[i][j]; } cout<<endl; } return 0; }

1188. 数字走向V

#include<bits/stdc++.h> using namespace std; int a[11][11]; int main(){ int n,sum=1; cin>>n; for(int i=n;i>=1;i--){ for(int j=n;j>=1;j--){ a[i][j]=sum; sum++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(3)<<a[i][j]; } cout<<endl; } return 0; }

1189. 数字走向VI

#include<bits/stdc++.h> using namespace std; int a[11][11]; int main(){ int n,sum=1; cin>>n; for(int i=1;i<=n;i++){ for(int j=n;j>=1;j--){ a[i][j]=sum; sum++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<setw(3)<<a[i][j]; } cout<<endl; } return 0; }

斜角

1193. 斜角II

#include<bits/stdc++.h> using namespace std; int a[105][105]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i+j<=n+1){ a[i][j]=i+j-1; }else{ a[i][j]=n*2-(i+j-1); } cout<<setw(3)<<a[i][j]; }cout<<endl; } return 0; }

1192. 斜角I

#include<bits/stdc++.h> using namespace std; int a[105][105]; int main(){ int n; cin>>n; for(int i=0;i<n;i++){ for(int j=i+1;j<=n+i;j++){ a[i][j]=j; cout<<setw(3)<<a[i][j]; }cout<<endl; } return 0; }

拐角

1196. 拐角I

#include<bits/stdc++.h> using namespace std; int a[105][105]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==1||j==1)cout<<setw(3)<<1; else if(i==2||j==2)cout<<setw(3)<<2; else if(i==3||j==3)cout<<setw(3)<<3; else if(i==4||j==4)cout<<setw(3)<<4; else if(i==5||j==5)cout<<setw(3)<<5; else if(i==6||j==6)cout<<setw(3)<<6; else if(i==7||j==7)cout<<setw(3)<<7; else if(i==8||j==8)cout<<setw(3)<<8; else if(i==9||j==9)cout<<setw(3)<<9; else if(i==10||j==10)cout<<setw(3)<<10; }cout<<endl; } return 0; }

1197. 拐角II

#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { int n; int a[10][10]; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (j <= i) { a[i][j] = n + 1 - i; cout << setw(3) << a[i][j]; } else { a[i][j] = n + 1 - j; cout << setw(3) << a[i][j]; } } cout << endl; } return 0; }

1198. 拐角III

#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { int n; int a[10][10]; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (n + 1 - j > n + 1 - i) { a[i][j] = n + 1 - j; cout << setw(3) << a[i][j]; } else { a[i][j] = n + 1 - i; cout << setw(3) << a[i][j]; } } cout << endl; } return 0; }

二维数组可能得告一段落,下一次在教大家

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/3 3:05:26

Zotero终极整理指南:如何一键自动化你的文献管理流程

还在为杂乱无章的文献库头痛吗&#xff1f;每天花费大量时间手动修正文献格式、查找期刊缩写、检测重复条目&#xff1f;今天我要分享的Zotero Linter插件&#xff0c;将彻底改变你的文献管理方式&#xff01;通过智能自动化技术&#xff0c;让你的文献库从"混乱仓库"…

作者头像 李华
网站建设 2026/4/2 13:31:56

Entity、VO、DTO、Form 对象详解

概述在项目中&#xff0c;我们使用不同的对象模型来处理不同场景的数据&#xff0c;这是分层架构的重要体现。为什么需要多种对象&#xff1f;&#x1f510; 安全性&#xff1a;防止敏感数据泄露&#x1f3af; 职责分离&#xff1a;每个对象只关注自己的职责&#x1f504; 灵活…

作者头像 李华
网站建设 2026/4/1 20:46:23

GoatCounter无cookie访客跟踪:终极隐私保护方案技术揭秘

GoatCounter无cookie访客跟踪&#xff1a;终极隐私保护方案技术揭秘 【免费下载链接】goatcounter Easy web analytics. No tracking of personal data. 项目地址: https://gitcode.com/gh_mirrors/go/goatcounter 在当今隐私保护日益重要的互联网环境中&#xff0c;传统…

作者头像 李华
网站建设 2026/3/31 19:50:13

BetterNCM安装器:解锁网易云音乐无限可能的智能钥匙

BetterNCM安装器&#xff1a;解锁网易云音乐无限可能的智能钥匙 【免费下载链接】BetterNCM-Installer 一键安装 Better 系软件 项目地址: https://gitcode.com/gh_mirrors/be/BetterNCM-Installer 想要让网易云音乐变得更好用吗&#xff1f;BetterNCM安装器正是你需要的…

作者头像 李华
网站建设 2026/4/1 9:28:28

Elsevier Tracker:科研工作者的审稿进度智能追踪助手

Elsevier Tracker&#xff1a;科研工作者的审稿进度智能追踪助手 【免费下载链接】Elsevier-Tracker 项目地址: https://gitcode.com/gh_mirrors/el/Elsevier-Tracker 作为一名科研工作者&#xff0c;您是否经常为了追踪论文审稿进度而反复登录Elsevier系统&#xff1f…

作者头像 李华
网站建设 2026/4/2 12:42:58

Java毕设项目:基于java+springboot+vue互联网智慧医院体检平台的设计与实现基于springboot互联网智慧医院体检平台的设计与实现(源码+文档,讲解、调试运行,定制等)

博主介绍&#xff1a;✌️码农一枚 &#xff0c;专注于大学生项目实战开发、讲解和毕业&#x1f6a2;文撰写修改等。全栈领域优质创作者&#xff0c;博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java、小程序技术领域和毕业项目实战 ✌️技术范围&#xff1a;&am…

作者头像 李华