-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSharp.cs
47 lines (46 loc) · 1.29 KB
/
CSharp.cs
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
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
class Solution
{
static void Main(string[] args)
{
string[] inputs = Console.ReadLine().Split(' ');
int width = int.Parse(inputs[0]);
int height = int.Parse(inputs[1]);
char[,] grille = new char[height, width];
for (int i = 0; i < height; i++)
{
string line = Console.ReadLine();
for (int j = 0; j < width; j++){
grille[i, j] = line[j];
}
}
bool fin = false;
while(!fin)
{
fin = true;
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
if (grille[i, j] == '#' && i+1 < height){
if (grille[i+1, j] == '.'){
grille[i+1, j] = '#';
grille[i, j] = '.';
fin = false;
}
}
}
}
}
for (int i = 0; i < height; i++){
string s = "";
for (int j = 0; j < width; j++){
s = s + grille[i, j];
}
Console.WriteLine(s);
}
}
}