Muchisimas gracias la verdad, ahora sigo solo ya q tengo q hacer eso pero con 2 arrays mas xD pero el 2do empieza por 8 hasta 15 y el 3ero de 15 a 21
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
return bvalor != 0 && bvalor != bant
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace juego_de_cartas
{
class Program
{
static Random rnd = new Random(unchecked((int)DateTime.Now.Ticks));
public static int[] pozo1 = new int[7];
public static int valor = 0;
public int ant = 0;
static void Main(string[] args)
{
Repartir();
}
public static bool IsValid(int bvalor, int bant)
{
return ((bvalor != 0) && (bvalor != bant));
}
public static void Repartir()
{
for (int i = 0; i < pozo1.Length; i++)
{
pozo1[i] = GetValidValue(i);
Console.WriteLine("Array de indice {0}, valor: {1}", i, pozo1[i]);
}
Console.ReadKey();
}
public static int GetValidValue(int i)
{
int ant;
if (i == 0) ant = 0;
else ant = pozo1[i-1];
// no me acuerdo si es valido esta asignacion dejo una alternativa abajo
while (!IsValid(valor = (int)(rnd.NextDouble() * 8D), ant));
return valor;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace juego_de_cartas
{
class Program
{
Random rnd = new Random(unchecked((int)DateTime.Now.Ticks));
public int[] pozo1 = new int[7];
public int valor = 0;
public int ant = 0;
static void Main(string[] args)
{
Repartir();
}
public static bool IsValid(int bvalor, int bant)
{
if (bvalor == 0)
{
return false;
}
else
{
if (bvalor == bant)
{
return false;
}
else
{
return true;
}
}
}
public static void Repartir()
{
for (int i = 0; i < pozo1.Length; i++)
{
first:
valor = (int)(rnd.NextDouble() * 8D);
ant = valor;
if (IsValid(valor, ant))
{
pozo1[i] = valor;
Console.WriteLine("Array de indice {0}, valor: {1}", i, pozo1[i]);
}
else { goto first; }
}
Console.ReadKey();
}
}
}
Cita de: ハセヲ, en 27 Noviembre 2010, 19:17 PM
Diestro- Programacion - DIOS