chouisse / IT2105

0 stars 0 forks source link

IT2105_LabActivity4_CHUA #2

Open chouisse opened 3 hours ago

chouisse commented 3 hours ago

using System;

public class LabaratoryAct4_Chua { public static void Main(string[] args) { // Input Console.Write("No. of test cases: "); // input the number of test cases string input = Console.ReadLine(); int T = Convert.ToInt32(input);

    // used array
    string[] results = new string[T]; 

    // using For Loop for the Transpo Problem with String.Length method
    for (int i = 0; i < T; i++)
    {
        string TCinput = Console.ReadLine(); 
        int X = 0;
        int Y = 0;
        int amount = 0; 

        //Uber
        while (amount < TCinput.Length && TCinput[amount] != ' ')
        {
            X = X * 10 + (TCinput[amount] - '0');
            amount++;
        }
        amount++; 

        //Grab
        while (amount < TCinput.Length)
        {
            Y = Y * 10 + (TCinput[amount] - '0');
            amount++;
        }

        // result for input
        if (X < Y)
        {
            results[i] = "FIRST";
        }
        else if (X > Y)
        {
            results[i] = "SECOND";
        }
        else
        {
            results[i] = "ANY";
        }
    }

    // output
    Console.WriteLine("\nOUTPUT:");
    for (int i = 0; i < T; i++)
    {
        Console.WriteLine(results[i]);
    }
}

}

chouisse commented 3 hours ago

image