#25043: 一維陣列解法

#### a810594@gm.tnfsh.tn.edu.tw (076)

School : 國立臺南第一高級中學
ID : 146476
2021-08-21 19:08:32
c292. APCS2017-0304-3數字龍捲風 -- | From: [59.127.217.171] | Post Date : 2021-04-16 22:05

真心建議不要這麼做，這是我浪費數小時的結果

https://lin76.blogspot.com/2021/04/blog-post.html

#25584: Re:一維陣列解法

#### vic20050418@gmail.com (Wen Vic)

School : No School
ID : 153262
2021-11-25 09:57:02
c292. APCS2017-0304-3數字龍捲風 -- | From: [114.136.159.185] | Post Date : 2021-06-04 13:18

(3ms, 364KB)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

..

.

..

.

..

..

.

.

.

.

.

.

.

.

.

.

.

.

.

#include <iostream>

using namespace std;

int main()

{

ios_base::sync_with_stdio(false); cin.tie(0);

int n[2510]= { 0 };

int x, z, count=1, change=2;

cin >> x >> z;

for (int i = 1; i <= x*x; i++) cin >> n[i];

int current = x * (x / 2) + (x / 2) + 1;

cout << n[current];

int direct[4] = { -1 , -x , 1 , x };

for (int j = (x + x) - 2; j > 0; j--) {

for (int i = count; i > 0; i--) {

if (z == 0) current += direct[0];

else if (z == 1) current += direct[1];

else if (z == 2) current += direct[2];

else current += direct[3];

cout << n[current];

}

z++;

if (z > 3) z = 0;

change--;

if (change == 0) {

count++;

change = 2;

}

}

for (int k = count - 1; k > 0; k--) {

current += direct[z];

cout << n[current];

}

}

ZeroJudge Forum