Quisiera saber como podría hacer para que cuando el usuario me ingresa dos números iguales en la apuesta le tire error que no se pueden repetir dos números en una misma apuesta:
static bool Agregar(int[,] m, ref int tope) //agregar una apuesta
{
bool disponible = true;
bool repetido = true;
int i = 0;
while (i < 5)
{
try
{
Console.Write("\n" + "INGRESE NÚMERO (" + (i + 1) + ") : ");
m[tope, i] = Convert.ToInt32(Console.ReadLine());
repetido = true;
for (int x = 0; x < tope; x++)
{
if (m[tope, i] == m[tope, i])
{
i++;
}
}
if (repetido)
{
Console.WriteLine("repe");
}
disponible = true;
if (m[tope, i] >= 1 && m[tope, i] <= 48 && disponible == true)
{
i++;
}
else
{
disponible = false;
Console.WriteLine("Número no disponible para apostar (1-48)");
}
}
catch
{
Console.WriteLine("Número incorrecto");
}
}
tope++;
return disponible;
}
static void Main(string[] args)
{
nombres = new string[cantidad];
int[,] matriz = new int[cantidad, 5];
i
while (!salir)
{
Console.Clear();
Console.WriteLine("----------------------");
Console.WriteLine("PRIMER OBLIGATORIO");
Console.WriteLine("----------------------");
Console.WriteLine("1- AGREGAR UNA APUESTA");
Console.WriteLine("2- AGREGAR UNA APUESTA SORPRESA");
Console.WriteLine("3- ELIMINAR UNA APUESTA");
Console.WriteLine("4- NÚMEROS DE UN APOSTADOR");
Console.WriteLine("5- LISTADO COMPLETO DE APUESTAS");
Console.WriteLine("6- NÚMEROS QUE NO HAN ESTADO EN APUESTAS");
Console.WriteLine("7- SALIR");
try
{
Console.Write("INGRESE OPCIÓN (1-7) : ");
opcion = Convert.ToInt32(Console.ReadLine());
}
catch
{
Console.WriteLine("La opción es incorrecta (1-7)");
}
Console.Clear();
switch (opcion)
{
case 1:
Console.Clear();
Console.WriteLine("---------------------------------------------------------");
Console.WriteLine(" AGREGAR UNA APUESTA");
Console.WriteLine("---------------------------------------------------------\n");
if (tope < nombres.Length)
{
Console.Write("INGRESE NOMBRE : ");
nombres[tope] = Console.ReadLine();
if (nombres[tope] == "")
{
mensaje = mensaje + "Debe ingresar un nombre";
if (mensaje == "")
{
Console.WriteLine("Nombre ingresado correctamente");
}
else
{
Console.WriteLine(mensaje);
}
}
else
{
Agregar(matriz, ref tope);
Console.WriteLine();
Console.WriteLine("Se agrego correctamente su apuesta");
}
}
else
{
Console.WriteLine("No hay màs apuestas disponibes");
}
Console.ReadLine();
break;
....
lo que intente hacer yo esta mal , por las dudas!
Contains
...?