-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Almost_Rectangle.cpp
More file actions
88 lines (86 loc) · 1.73 KB
/
B_Almost_Rectangle.cpp
File metadata and controls
88 lines (86 loc) · 1.73 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
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(int *b, int x, int n)
{
for (int i = 0; i < n; i++)
{
if (b[i] == x)
{
cout << i + 1 << endl;
return;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin >> t;
while (t--)
{
int n;
cin >> n;
char arr[n][n];
int x1 = -1, x2 = -1, y1, y2;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cin >> arr[i][j];
if (arr[i][j] == '*')
{
if (x1 == -1)
{
x1 = i;
y1 = j;
}
else
{
x2 = i;
y2 = j;
}
}
}
}
int x3, x4, y3, y4;
if (y1 == y2)
{
x3 = x1;
x4 = x2;
if (y1 > 0)
y3 = y4 = 0;
else
y3 = y4 = n - 1;
}
else if (x1 == x2)
{
y3 = y1;
y4 = y2;
if (x1 > 0)
x3 = x4 = 0;
else
x3 = x4 = n - 1;
}
else
{
x3 = x2;
y3 = y1;
x4 = x1;
y4 = y2;
}
arr[x3][y3] = '*';
arr[x4][y4] = '*';
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cout << arr[i][j];
}
cout << endl;
}
}
return 0;
}