1067 - Guessing Game

Discussion around the problems of the COJ.
Forum rules
Remember that posting AC code is not allowed here. If you are going to ask a question or to post a solution, describe your algorithm instead. Posting AC code will be penalized.
Post Reply
User avatar
dovier
Posts: 1143
Joined: 9 years ago
Location: Havana, Cuba
Gender: Male
Cuba

1067 - Guessing Game

Post by dovier » 9 years ago




AlexG13
Posts: 2
Joined: 6 years ago
Gender: None specified

1067 - Guessing Game - Help Needed!

Post by AlexG13 » 5 years ago

Hola
Tengo un problema que resolver que hasta ahora se me ha presentado sin sentido pues cada uno de los posibles casos de prueba tengo me da una respuesta correcta pero no es aceptada por el jurado online. EL problema es el 1067 sobre el juego de adivinar el numero que escoge el otro jugador. Este problema resulta ser bastante problemático para muchos porque veo que han tropezado bastante con este. Cualquier sugerencia es bienvenida...Gracias.

AlexG13
Posts: 2
Joined: 6 years ago
Gender: None specified

Re: 1067 - Guessing Game - Help Needed!

Post by AlexG13 » 5 years ago

Este es mi código en C# hasta el momento con este problema, el cual no es aceptado por algún error u omisión de mi parte, o talvez el problema no esta muy bien definido.

using System;

namespace coj
{
class Program
{
static void Main(string[] args)
{
string input, answer;
int min =0, max = 11, n;

while (!"0".Equals(input = Console.ReadLine()))
{
n = int.Parse(input);
answer = Console.ReadLine();
switch (answer)
{
case "too high":
max = n;
break;
case "too low":
min = n;
break;
case "right on":
if (min == 0 && max == 11 && n >= 1 && n <= 10)
Console.WriteLine("Stan may be honest");
else
{
if (n <= min || n >= max || max == 1 || min == 10)
Console.WriteLine("Stan is dishonest");
else
Console.WriteLine("Stan may be honest");
min = 0;
max = 11;
}
break;
}
}
}
}
}

Post Reply

Return to “Problem set”