Link do zadania: https://www.spoj.com/submit/TEST/id=22622268
Dostałem zadanie na spoje (TEST - Life, the Universe, and Everything) typu:
Input:
1
2
88
42
99
Output:
1
2
88
Gdy trafisz na 42 wyjdz. Wykonałem je w c# w bardzo pokrecony sposob. Poniższy kod mi działa, ale na spoje nie przechodzi testcasow. Pytanie dlaczego? Nie rozumiem tego systemu.
using System;
public class Solution
{
public static void Main()
{
int r1 = Convert.ToInt32(Console.ReadLine());
int r2 = Convert.ToInt32(Console.ReadLine());
int r3 = Convert.ToInt32(Console.ReadLine());
int r4 = Convert.ToInt32(Console.ReadLine());
int r5 = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < 5; i++)
{
if (r1 == 42)
{
break;
}
else
{
Console.WriteLine(r1);
}
if (r2 == 42)
{
break;
}
else
{
Console.WriteLine(r2);
}
if (r3 == 42)
{
break;
}
else
{
Console.WriteLine(r3);
}
if (r4 == 42)
{
break;
}
else
{
Console.WriteLine(r4);
}
if (r5 == 42)
{
break;
}
else
{
Console.WriteLine(r5);
}
}
Console.ReadKey();
}
}