0
First of all, I don’t have much experience with C#, I just know programming logic. I’m studying C# out of curiosity, it’s a language that always interested me.
I am studying for URI and I am not able to solve this exercise:
Read 4 integer values A, B, C and D. Next, if B is greater than C and if D is greater than A, and the sum of C and D is greater than the sum of A and B and if C and D are both positive and if variable A is even write the message "Accepted values", or write "Values not accepted".
The code I run in Visual Studio and works correctly, but when I send it to the URI it gives the error:
Runtime error
The code is like this:
using System;
class URI {
static void Main(string[] args) {
int a, b, c, d;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = int.Parse(Console.ReadLine());
d = int.Parse(Console.ReadLine());
if ( (b > c) && (d > a) && ((c + d) > (a + b)) && (c > 0 && d > 0) && (a % 2 == 0)) {
Console.WriteLine("Valores aceitos");
} else {
Console.WriteLine("Valores nao aceitos");
}
}
}
I did not validate the logic of the condition... but the console worked without errors for me, both in debug and in the release execution
– Leandro Angelo
So it worked for me too. I just don’t understand why the URI doesn’t accept the code
– Julio Cesar
Ah, I may have to create an array for the input values, I thought of that now.
– Julio Cesar
got it, you want to pass the values as argument
– Leandro Angelo
Did you solve it? @Juliocesar
– Leandro Angelo