Problem: In Chefland, a tennis game involves 4 referees. Each referee has to point out whether he considers the ball to be inside limits or outside limits. The ball is considered to be IN if and only if all the referees agree that it was inside limits.
Given the decision of the 4 referees, help Chef determine whether the ball is considered inside limits or not.
Input Format: The first line of input will contain a single integer TT, denoting the number of test cases. Each test case consists of a single line of input containing 4 integers R1, R2, R3, R4.
R can be either 0 or 1. If the input is 0, the ball is inside limits, and the output should be "IN". If the input is 1, the ball is outside limits, and output should be "OUT".
My Code:
using System;
public class Test
{
public static void Main()
{
int t = Convert.ToInt32(Console.ReadLine());
int r1 = Convert.ToInt32(Console.ReadLine());
int r2 = Convert.ToInt32(Console.ReadLine());
int r3 = Convert.ToInt32(Console.ReadLine());
int r4 = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < t; i++)
{
if(r1 == 0 && r2 == 0 && r3 == 0 && r4 == 0)
{
Console.WriteLine("IN");
}
else
{
Console.WriteLine("OUT");
}
}
}
}
The Error: Unhandled Exception: System.FormatException: Input string was not in a correct format.
Disclaimer: I've already checked other solutions, which I understand, for example solving this using an array,but I don't get why this solution doesn't work. Can someone help me understand please?