-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.cpp
78 lines (64 loc) · 2.04 KB
/
convert.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
#include <bits/stdc++.h>
using namespace std;
int main() {
ifstream fin;
fin.open("Resources/Maps/map5.txt", ios::in);
int row, col;
fin >> row >> col;
int** matrix = new int*[row];
for(int i = 0; i < row; i++) {
matrix[i] = new int[col];
for(int j = 0; j < col; j++) {
fin >> matrix[i][j];
}
}
fin.close();
ofstream fout;
fout.open("Resources/Maps/map1.txt", ios::out);
for(int i = 1; i < row-1; i++)
for(int j = 1; j < col-1; j++) {
if(matrix[i][j] == 13) {
if(matrix[i-1][j] == 0) {
matrix[i][j] = 14;
matrix[i-1][j] = 2;
}
if(matrix[i+1][j] == 0)
matrix[i+1][j] = 11;
if(matrix[i][j-1] == 0)
matrix[i][j-1] = 8;
if(matrix[i][j+1] == 0)
matrix[i][j+1] = 9;
}
}
for(int i = 1; i < row-1; i++)
for(int j = 1; j < col-1; j++) {
if(matrix[i][j] == 14) {
if(matrix[i+1][j] == 0)
matrix[i+1][j] = 11;
if(matrix[i-1][j] == 0)
matrix[i-1][j] = 2;
if(matrix[i][j-1] == 0)
matrix[i][j-1] = 6;
if(matrix[i][j+1] == 0)
matrix[i][j+1] = 7;
if(matrix[i-1][j-1] == 0 and matrix[i][j-1] != 13)
matrix[i-1][j-1] = 1;
if(matrix[i-1][j+1] == 0 and matrix[i][j+1] != 13)
matrix[i-1][j+1] = 3;
if(matrix[i-1][j-1] == 13)
matrix[i-1][j] = 5;
if(matrix[i-1][j+1] == 13)
matrix[i-1][j] = 4;
}
}
fout << row << endl << col << endl;
for(int i = 0; i < row; i++) {
for(int j = 0; j < col; j++) {
fout << matrix[i][j] << " ";
}
fout << endl;
}
cout << "complete" << endl;
fout.close();
return 0;
}