[푸르딩~] 100개의 방, 100명의 사람 배수의 방문 열기 (새로 열린것은 닫기)
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
/* 100개의 방이 있다. 100명의 사람 배수의 방문 번호를 연다 (닫혀있으면 닫는다), 닫힌문0, 열린문1 */
int[] Room = new int[101];
int n,l;
int result = 0;
for (n = 1; n <= 100; n++)
{
for (l = 1; l <= 100; l++)
{
result = n * l;
if (result > 100)
{
continue;
}
else
{
if (Room[result] == 1)
{
Room[result] = 0;
}
else
Room[result] = 1;
}
}
}
for (int a = 1; a <= 100; a++)
{
if (Room[a] == 1)
{
Console.WriteLine("{0}번 방이 열려있습니다.", a);
}
}
}
}
}
아 정말 그지같이 짰다 -_-;