-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmap_function.cpp
119 lines (105 loc) · 1.5 KB
/
map_function.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include<bits/stdc++.h>
using namespace std;
// x= horizonal y= going to bottom right z=going to bottom left
int grid[201][201];
int n=10;
void map_func(vector<int> l, int x, int y, int z)
{
if(x)
{
for(int i=100-x+1;i<=100+x-1;i++)
grid[x][i]=l[i+x-101];
}
else if(y)
{
int i=101-y, j=y;
int k=0,p=-1;
while(j<=n&&k<l.size())
{
grid[j][i]=l[k++];
if(p==-1)
{
j++;
p=1;
}
else
{
i++;
p=-1;
}
}
}
else
{
int i=99+y, j=y;
int k=0,p=-1;
while(j<=n&&k<l.size())
{
grid[j][i]=l[k++];
if(p==-1)
{
j++;
p=1;
}
else
{
i--;
p=-1;
}
}
}
}
void print_grid()
{
for (int i=1;i<=n;i++)
{
for(int k=0;k<n-i;k++)
cout<<" ";
for(int j=100-i+1;j<=100+i-1;j++)
{
if(grid[i][j]==1)
cout<<"*";
else
cout<<"%";
}
for(int k=0;k<n-i;k++)
cout<<" ";
cout<<endl;
}
/* for(int i=0;i<11;i++)
{
for(int j=50;j<150;j++)
{
if(grid[i][j]==2)
cout<<"$";
else if(grid[i][j]==1)
cout<<"*";
else if(grid[i][j]==0)
cout<<"#";
}
cout<<endl;
}*/
}
void initialize()
{
for(int i=0;i<201;i++)
{
for(int j=0;j<201;j++)
grid[i][j]=2;
}
}
int main()
{
vector<int> l;
l.push_back(1);
l.push_back(1);
l.push_back(1);
l.push_back(1);
l.push_back(1);
l.push_back(1);
l.push_back(1);
initialize();
map_func(l,0,7,0);
print_grid();
return 0;
}