I would like to know how I could do it so that when the user enters two equal numbers in the bet, I throw error that can not repeat two numbers in the same bet:
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;
....
What I try to do is wrong, just in case!