Skip to content

Instantly share code, notes, and snippets.

@Chubek
Created July 7, 2016 07:11
Show Gist options
  • Save Chubek/d8b4b109c71e0217add2260068904ff7 to your computer and use it in GitHub Desktop.
Save Chubek/d8b4b109c71e0217add2260068904ff7 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BlackAndWhiteImage
{
class Program
{
static void Main(string[] args)
{
string input = Console.ReadLine();
string[] inputsplit = input.Split();
byte[,] imageArray = new byte[int.Parse(inputsplit[0]), int.Parse(inputsplit[1])];
for (int i = 0; i < int.Parse(inputsplit[0]); i++)
{
for (int j = 0; j < int.Parse(inputsplit[1]; j++)
{
switch (inputsplit[i])
{
case ("N"):
if (i > 0)
{
i -= 1;
}
break;
case ("S"):
if (i < int.Parse(inputsplit[0]))
{
i += 1;
}
break;
case ("E"):
if (j > 0)
{
j -= 1;
}
break;
case ("W"):
if (j < int.Parse(inputsplit[1]))
{
j += 1;
}
break;
case ("P"):
imageArray[i, j] = 1;
break;
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment