CSharp · Console
using System;
public class Program
{
public static void Main()
{
const int numberOfLines = 8;
string[,] matrix = new string[8, 8];
for (int row = 0; row < numberOfLines; row++)
{
int shift = 0;
int input = int.Parse(Console.ReadLine());
for (int col = numberOfLines - 1; col >= 0; col--)
{
int digit = input & (1 << shift);
digit = digit >> shift;
matrix[row, col] = digit.ToString();
shift++;
}
}
for (int i = 0; i < numberOfLines - 1; i++)
{
for (int row = numberOfLines - 2; row >= 0; row--)
{
for (int col = 0; col < numberOfLines; col++)
{
if (matrix[row, col] == "1")
{
if (matrix[row + 1, col] == "0")
{
matrix[row + 1, col] = "1";
matrix[row, col] = "0";
}
}
}
}
}
for (int row = 0; row < numberOfLines; row++)
{
string result = null;
for (int col = 0; col < numberOfLines; col++)
{
result += matrix[row, col];
}
result = Convert.ToInt32(result, 2).ToString();
Console.WriteLine(result);
}
}
}