首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
sky952
2026年3月24日 14:32
旋转方阵 (C语言)题解:
P1216
回复 0
|
赞 6
|
浏览 88
#include <stdio.h> int main() { int n; scanf("%d", &n); int a[25][25] = {0}; int dx[4] = {1, 0, -1, 0}; // 上 右 下 左 int dy[4] = {0, 1, 0, -1}; int x = 0, y = 0; // 起点:左上角 ...
太一
2026年3月17日 17:27
旋转方阵 题解:注意左对齐
P1216
回复 1
|
赞 17
|
浏览 277
#include<iostream> #include<cmath> #include<algorithm> #include<string> #include<map> using namespace std; int main() { int n; cin >> n; int top = 0, bottom = n - 1, left = 0, right = n - 1, arr[20][20], num = ...
彻底死去
2026年3月17日 21:24
旋转方阵 题解:
P1216
回复 0
|
赞 6
|
浏览 121
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string> #include<cstring> using namespace std; int main() { int n; cin >> n; int res[20][20] = { 0 }; int dx[] = { 1,0,-1,0 }; int dy[] = ...
miracle233
2026年3月16日 12:26
旋转方阵 题解:我真服了这个间距空格
P1216
回复 0
|
赞 3
|
浏览 202
#include 使用命名空间标准; int main(){ int n,count=0,width=0,max; cin>>n; max=n*n; while(max>0){ width++; max/=10;/*不是我就想问了,你既然都让对齐了,后面直接setw(width+1)不得 了,还必须输出setw(4),因为n<=20,n*n<=400,3位数+1位空格,我真服了。。。。。。*/ } 向量> vec(n,vector(n,0)); for(int i=0;i<(n+1)/2;i++){ for(int ...
岸上的乌龟
2026年3月13日 21:17
旋转方阵 题解:贪吃蛇解法,当到数组尽头或遇到已经填入的位置,换方向
P1216
回复 0
|
赞 13
|
浏览 286
换方向需要找一下规律,逆时针,i和j的改变方式是有规律的 输出也很关键,用printf("%-4d",buf[x][y]);左对齐 #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int buf[25][25]; memset(buf,0,sizeof(buf)); int i=0,...
王艺道
2026年3月13日 15:38
旋转方阵 题解:
P1216
回复 0
|
赞 6
|
浏览 125
#include<bits/stdc++.h> using namespace std; int res[22][22]; int main(){ int n; cin >> n; int mx[] = {1, 0, -1, 0}; int my[] = {0, 1, 0, -1}; int k = 1, f = 0; &nb...
winner748
2026年2月9日 16:15
旋转方阵 题解:
P1216
回复 1
|
赞 52
|
浏览 800
#include<bits/stdc++.h> using namespace std; int a[25][25]; int main(){ int n; // 下右上左 int dy[4] = {0,1,0,-1}; int dx[4] = {1,0,-1,0}; int x = 1,y = 1; cin >> n; int cnt = 1...
userCao
2026年3月10日 17:23
旋转方阵 题解:C语言题解
P1216
回复 0
|
赞 19
|
浏览 282
#include<stdio.h> int arr[25][25]={0}; int main() { int n; scanf("%d",&n); int x=1; for(int k=0;k<n/2;k++)//若变成等于不用后续特殊处理了 { for(int i=k,j=k;i<n-k...
无名吟
2026年3月10日 11:40
旋转方阵 C语言题解
P1216
回复 0
|
赞 7
|
浏览 174
printf("%-4d", arr[i][j]); 注意格式化输出 #include<stdio.h> int main() { int n; scanf("%d", &n); int arr[21][21] = { 0 }; int i = 0, j = 1; for (int k = 1; k <= n * n; k++) { i++; while (i <= n && arr[...
Cat111
2026年3月5日 23:26
旋转方阵 题解:
P1216
回复 0
|
赞 29
|
浏览 340
#include <bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d",&n); int num=1; int a[20][20]={{0}}; int top=0,bottom=n-1,left=0,right=n-1; while(num<=n*n){ for(int i=top;i<=bottom;i++) a[i][left]=num++; left++; for(int i=left;i<=right...
1
2
3
...
5
题目
旋转方阵
题解数量
48
发布题解
在线答疑
热门题解
1
旋转方阵 题解:
2
旋转方阵 题解:
3
旋转方阵(模拟) 题解:
4
旋转方阵 题解:C++ 需要注意结果的输出格式
5
旋转方阵 题解:
6
旋转方阵 题解:
7
旋转方阵 题解:
8
旋转方阵 题解:
9
c 解法:
10
旋转方阵 题解:方块收缩模拟输出