-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshuttle.cpp
54 lines (52 loc) · 986 Bytes
/
shuttle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
TASK:shuttle
LANG:C++
*/
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int n, cnt;
int main()
{
freopen("shuttle.in", "r", stdin);
freopen("shuttle.out", "w", stdout);
scanf("%d", &n);
int space = n + n % 2;
cnt = 0;
for (int i = 1; i <= n; ++i)
for (int j = 0; j <= i; ++j)
{
if (i % 2)
{
if (space % 2) space += 2;
else space -= 1;
}
else
if (space % 2) space += 1;
else space -= 2;
printf("%d", space + !(n % 2));
++cnt;
if (cnt % 20 == 0) printf("\n");
else printf(" ");
}
for (int i = n - 1; i > 0; --i)
for (int j = 0; j <= i; ++j)
{
if (i % 2)
{
if (space % 2) space += 2;
else space += 1;
}
else
if (space % 2) space -= 1;
else space -=2;
printf("%d", space + !(n % 2));
++cnt;
if (cnt % 20 == 0) printf("\n");
else printf(" ");
}
printf("%d\n", n + 1);
//system("pause");
return 0;
}