0

```
#include <iostream>
#include <fstream>
using namespace std;
char a[11][11];
bool free(int x, int y)
{
if (x < 1 && x > 10)
{
return false;
}
if (y < 1 && y > 10)
{
return false;
}
for (int i = -1; i < 1; i++)
{
for (int j = -1; j < 1; j++)
{
if (a[x + i][y + j] != '.')
{
return false;
}
cout << endl;
}
}
return true;
}
int main()
{
int max = 20;
int unused = 0;
ifstream sisf("laevtest.01.sis");
ofstream valf("laev.val");
int k = 0;
for (int i = 1; i < 11; i++)
{
for (int j = 1; j < 11; j++)
{
sisf >> a[i][j];
if (a[i][j] == '#')
{
k++;
}
}
}
unused = max - k;
// Fill up
for (int i = 0; i < 12; i++)
{
a[i][0] = '.'; a[i][11] = '.';
a[0][i] = '.'; a[11][i] = '.';
}
bool ok = true;
for (int i = 1; i < 11; i++)
{
for (int j = 1; j < 11; j++)
{
for (int u = 0; u < unused - 1; u++)
{
// Horisontaalselt paigutamine (laius)
ok = free(i, j + u);
if (ok)
{
a[i][i + u] = '#';
}
}
for (int u = 0; u < unused - 1; u++)
{
// Vertikaalselt paigutamine
ok = free(i + u, j);
if (ok)
{
a[i + u][j] = '#';
}
}
}
}
for (int i = 1; i < 11; i++)
{
for (int j = 1; j < 11; j++)
{
valf << a[i][j];
}
valf << endl;
}
sisf.close();
valf.close();
return 0;
}
```

Output:

```
#..#..#.##
#..#......
...#.#.##.
.....#....
.#...#....
.....#....
.#........
.#....#...
.#........
..........
```

True output is:

```
#..#..#.##
#..#......
...#.#.##.
.....#....
.#.#.#....
.....#....
.#........
.#....#...
.#........
..........
```