-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeup 1477.cpp
More file actions
90 lines (87 loc) · 1.14 KB
/
codeup 1477.cpp
File metadata and controls
90 lines (87 loc) · 1.14 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <algorithm>
#define X_Pos 101
#define Y_Pos 101
long long int arr[X_Pos][Y_Pos]{{0, },};
int main()
{
long long int n, m;
long long int count = 1;
std::cin >> n >> m;
int p;
int cycle = 0;
int k = 1;
int x, y;
if (n <= m)
{
for(int i=0; i<m; i++)
{
cycle = 0;
for(int j=0; j<=i; j++)
{
if(cycle<n)
{
arr[j][i-j] = count;
count++;
cycle++;
}
}
}
p = n;
for (int d = 1; d < n; d++)
{
cycle=0;
y = 0;
for(int j = m; j>d; j--)
{
if(cycle<p-1)
{
arr[d+y][j-1] = count;
count++;
y++;
cycle++;
}
}
p--;
}
}
else
{
for(int u = 0; u<n; u++)
{
for(int i =0; i<m; i++)
{
for(int j =0; j<m; j++)
{
arr[i][j] = count;
count++;
}
}
}
/* p = n;
for (int d = 1; d < n; d++)
{
cycle=0;
y = 0;
for(int j = m; j>d; j--)
{
if(cycle<p-1)
{
arr[d+y][j-1] = count;
count++;
y++;
cycle++;
}
}
p--;
}*/
}
for (int i = 0; i < n+10; i++)
{
for (int j = 0; j < m+10; j++)
{
std::cout << arr[i][j] << " ";
}
std::cout << std::endl;
}
}