TOPIC

runtime Error

ahenschel0 asked 3 years ago

estou tendo runtime Error e não sei porque.

using System;

class URI {

static void Main(string[] args) { 

   int a, b, c;
        string[] nums;

        while ((nums = Console.ReadLine().Split()) != null && nums[0] != "")
        {

            a = int.Parse(nums[0]);
            b = int.Parse(nums[1]);
            c = int.Parse(nums[2]);

            if (a == b && b == c)
            {
                Console.WriteLine("*");

            }
            else if (a == b && b != c)
            {
                Console.WriteLine("C");
            }
            else if (a != b && b == c)
            {
                Console.WriteLine("A");

            }
            else if (a == c && c != b)
            {
                Console.WriteLine("B");

            }

        }
}

Remember not post solutions. Your post may be reviewed by our moderators.

  • WesleyDias replied 3 years ago

    Olá, ALAN HENSCHEL, provavelmente seu problema é na hora de detectar o EOF:

    while ((nums = Console.ReadLine().Split()) != null && nums[0] != "")

    Exemplo de como fazer EOF em C#:

    using System; 
    
    class URI {
    
        static void Main(string[] args) { 
    
            while(true){
                string entrada = Console.ReadLine();
                if(string.IsNullOrEmpty(entrada)) break;
    
                 // SEU CODIGO AQUI
                // FATIE A STRING DEPOIS DE VERIFICAR SE ELA NAO EH VAZIA
                string[] nums = entrada.Split(); 
    
            }
        }
    }

    Espero ter ajudado :D

    MOD