elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  AYUDA y EJERCICIO - Truco de cartas en C#
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: AYUDA y EJERCICIO - Truco de cartas en C#  (Leído 7,102 veces)
Edu


Desconectado Desconectado

Mensajes: 1.082


Ex XXX-ZERO-XXX


Ver Perfil
AYUDA y EJERCICIO - Truco de cartas en C#
« en: 10 Diciembre 2010, 22:43 pm »

No se si conocen el truco de las cartas que vas creando 3 mazos poniendo:

                            MAZO 1 - - MAZO 2- - MAZO3

abajo                 -CartaNº1  -  CartaNº2  -  CartaNº3
arriba                 -CartaNº4  -  CartaNº5   - CartaNº6
arriba de arriba -CartaNº7  -  CartaNº8   - CartaNº9

Y el otro tiene q elegir una carta, pensarla no decirla, y decir en q mazo se encuentra la carta que penso. Entonces si por ejemplo penso la carta Nº7, dira que se encuentra en el mazo numero 1 y entonces lo q hace el repartidor es meter ese mazo en el medio de los tres para luego repartir asi:

     MAZO 1 - - MAZO 2- - MAZO3

abajo                 -CartaNº9  -  CartaNº6 -  CartaNº3
arriba                 -CartaNº7  -  CartaNº4   - CartaNº1
arriba de arriba -CartaNº8  -  CartaNº5   - CartaNº2

Eso lo haces 3 veces y aclaro q el numero de cartas con el q se tiene q hacer son con 21 cartas. Porque entonces luego de la tercera vez que fue diciendo en q mazo estaba la que pensaba y vos ibas poniendo ese mazo en el medio de los 3 para luego repartir denuevo... Ya una vez metida la ultima vez el mazo en el medio ( la tercera vez) cuentas 11 cartas empezando desde arriba claro, y esa sera la carta q nuestro amigo penso.

Ahora si no lo conocian practiquenlo con cartas primero y luego a ver si pueden hacerlo en C# modo consola xD


En línea

Edu


Desconectado Desconectado

Mensajes: 1.082


Ex XXX-ZERO-XXX


Ver Perfil
Re: AYUDA y EJERCICIO - Truco de cartas en C#
« Respuesta #1 en: 10 Diciembre 2010, 22:50 pm »

A mi me interesan como pueden lograrlos ustedes pero si pueden terminar el mio o mirar como lo he echo hasta donde llegue, estaria bueno ya que no puedo seguir :S talvez alguien lo arregla y lo muestra como su propia solucion.

Pero talvez algunos quieren entrenerse un buen rato y por eso lo dejo para el q quiera verlo y el q no que intente por su cuenta xD
Espero que se unan muchos, aca les dejo hasta donde llegue yo, espero tambien q alguien me lo termine xD

[spoiler]
Código
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.    class Program
  10.    {
  11.        private static int[] Mazo = new int[21];
  12.        private static int[] SegundaR = new int[21];
  13.        private static int[] TerceraR = new int[21];
  14.        private static int[] CuartaR = new int[21];
  15.        private static int[] Pozo1 = new int[7];
  16.        private static int[] Pozo2 = new int[7];
  17.        private static int[] Pozo3 = new int[7];
  18.  
  19.  
  20.        private static int opc;
  21.        private static int j = 0;
  22.        private static int g = 0;
  23.        private static int h = 0;
  24.        private static int f = 20;
  25.  
  26.        public static void Mostrar2(int[] pozon1, int[] pozon2, int[] pozon3, int numpozon)
  27.        {
  28.            Mostrar(pozon1,pozon2,pozon3,numpozon);
  29.  
  30.        }
  31.  
  32.  
  33.        public static void Mostrar(int[] pozito1, int[] pozito2, int[] pozito3, int numpozo)
  34.        {
  35.  
  36.            int mistake = 0;
  37.            do
  38.            {
  39.                Console.Clear();
  40.                Console.WriteLine();
  41.                Console.WriteLine("  - Elegiste el pozo numero {0}", numpozo);
  42.                Console.WriteLine();
  43.                try
  44.                {
  45.                    Console.WriteLine("-  POZO 1  -");
  46.                    Console.WriteLine();
  47.                    for (int i = 0; i < pozito1.Length; i++)
  48.                    {
  49.                        Console.WriteLine("Carta Nº: {0}", pozito1[i]);
  50.  
  51.  
  52.                    }
  53.                    Console.WriteLine(); Console.WriteLine();
  54.                    Console.WriteLine("-  POZO 2  -");
  55.                    Console.WriteLine();
  56.                    for (int i = 0; i < pozito2.Length; i++)
  57.                    {
  58.                        Console.WriteLine("Carta Nº: {0}", pozito2[i]);
  59.  
  60.  
  61.                    }
  62.  
  63.                    Console.WriteLine(); Console.WriteLine();
  64.                    Console.WriteLine("-  POZO 3  -");
  65.                    Console.WriteLine();
  66.                    for (int i = 0; i < pozito3.Length; i++)
  67.                    {
  68.                        Console.WriteLine("Carta Nº: {0}", pozito3[i]);
  69.  
  70.  
  71.                    }
  72.  
  73.                    Console.WriteLine(); Console.WriteLine();
  74.  
  75.                    Console.Write("  - Vuelve a escribir el pozo donde se encuentra tu numero: ");
  76.  
  77.                    opc = int.Parse(Console.ReadLine());
  78.  
  79.                    if ((opc != 1) && (opc != 2) && (opc != 3))
  80.                    {
  81.                        Console.Clear();
  82.                        Console.WriteLine();
  83.                        Console.WriteLine("  - NUMERO INCORRECTO, SON 3 POZOS SOLAMENTE xD");
  84.                        mistake = 0;
  85.                        Console.WriteLine();
  86.                        Console.WriteLine(" Presione una tecla para volver..");
  87.                        Console.ReadKey();
  88.                    }
  89.                    else mistake = 1;
  90.  
  91.                }
  92.                catch
  93.                { }
  94.            } while (mistake == 0);
  95.  
  96.            int k = 0;
  97.            switch (opc)
  98.            {
  99.                case 1:
  100.                    f = 20;
  101.                    h = 0;
  102.                    g = 0;
  103.  
  104.                    for (int i = 7; i < 14; i++)
  105.                    {
  106.                        TerceraR[k] =  SegundaR[i];
  107.                        k++;
  108.                    }
  109.  
  110.                    for (int i = 0; i < 7; i++)
  111.                    {
  112.                        TerceraR[k] = SegundaR[i];
  113.                        k++;
  114.                    }
  115.  
  116.                    for (int i = 14; i < 21; i++)
  117.                    {
  118.                        TerceraR[k] = SegundaR[i];
  119.                        k++;
  120.                    }
  121.  
  122.                    for (int i = 0; i < 7; i++)
  123.                    {
  124.  
  125.                        Pozo1[i] = SegundaR[f];
  126.                        f--;
  127.  
  128.                        Pozo2[g] = SegundaR[f];
  129.                        f--;
  130.                        Pozo3[h] = SegundaR[f];
  131.  
  132.                        g++;
  133.                        h++;
  134.                        f--;
  135.  
  136.  
  137.                    }
  138.  
  139.  
  140.  
  141.                    Mostrar2(Pozo1, Pozo2, Pozo3, 1);
  142.  
  143.                    break;
  144.  
  145.  
  146.                case 2:
  147.  
  148.                    f = 20;
  149.                    h = 0;
  150.                    g = 0;
  151.  
  152.                    for (int i = 14; i < 21; i++)
  153.                    {
  154.                        TerceraR[k] = SegundaR[i];
  155.                        k++;
  156.                    }
  157.  
  158.  
  159.  
  160.  
  161.                    for (int i = 7; i < 14; i++)
  162.                    {
  163.                        TerceraR[k] = SegundaR[i];
  164.                        k++;
  165.                    }
  166.  
  167.  
  168.  
  169.  
  170.                    for (int i = 0; i < 7; i++)
  171.                    {
  172.                        TerceraR[k] = SegundaR[i];
  173.                        k++;
  174.                    }
  175.  
  176.  
  177.                    for (int i = 0; i < 7; i++)
  178.                    {
  179.  
  180.                        Pozo1[i] = SegundaR[f];
  181.                        f--;
  182.  
  183.                        Pozo2[g] = SegundaR[f];
  184.                        f--;
  185.                        Pozo3[h] = SegundaR[f];
  186.  
  187.                        g++;
  188.                        h++;
  189.                        f--;
  190.  
  191.  
  192.                    }
  193.  
  194.  
  195.                    Mostrar2(Pozo1, Pozo2, Pozo3, 2);
  196.                    break;
  197.  
  198.                case 3:
  199.                    f = 20;
  200.                    h = 0;
  201.                    g = 0;
  202.  
  203.                    for (int i = 0; i < 7; i++)
  204.                    {
  205.                        TerceraR[k] = SegundaR[i];
  206.                        k++;
  207.                    }
  208.  
  209.  
  210.                    for (int i = 14; i < 21; i++)
  211.                    {
  212.                       TerceraR[k] = SegundaR[i];
  213.                        k++;
  214.                    }
  215.  
  216.                    for (int i = 7; i < 14; i++)
  217.                    {
  218.                        TerceraR[k] = SegundaR[i];
  219.                        k++;
  220.                    }
  221.  
  222.                    for (int i = 0; i < 7; i++)
  223.                    {
  224.  
  225.                        Pozo1[i] = SegundaR[f];
  226.                        f--;
  227.  
  228.                        Pozo2[g] = SegundaR[f];
  229.                        f--;
  230.                        Pozo3[h] = SegundaR[f];
  231.  
  232.                        g++;
  233.                        h++;
  234.                        f--;
  235.  
  236.  
  237.                    }
  238.  
  239.  
  240.  
  241.                    Mostrar2(Pozo1, Pozo2, Pozo3, 3);
  242.                    break;
  243.  
  244.            }
  245.            Console.ReadKey();
  246.        }
  247.  
  248.        public static bool NumExists(int Num, int MaxPos)
  249.        {
  250.            bool resultado = false;
  251.            for (int i = 0; i < MaxPos; i++)
  252.                if (Mazo[i] == Num)
  253.                {
  254.                    resultado = true;
  255.                    break;
  256.                }
  257.            return resultado;
  258.        }
  259.  
  260.  
  261.  
  262.        public static void RandomNumbers()
  263.        {
  264.            Random Rnd = new Random(unchecked((int)DateTime.Now.Ticks));
  265.            for (int i = 0; i < Mazo.Length; i++)
  266.                do
  267.                {
  268.                    Mazo[i] = Rnd.Next(1,22);
  269.                } while (NumExists(Mazo[i], i) == true);
  270.            Rnd = null;
  271.        }
  272.  
  273.  
  274.  
  275.  
  276.        static void Main(string[] args)
  277.        {
  278.            Console.BackgroundColor = ConsoleColor.Black;
  279.            Console.ForegroundColor = ConsoleColor.Green;
  280.            Console.Title = "Adivinador";
  281.            Console.WindowHeight = 40;
  282.            Console.WindowWidth = 90;
  283.  
  284.            int error = 0;
  285.  
  286.            do
  287.            {
  288.  
  289.            RandomNumbers();
  290.  
  291.                Console.Clear();
  292.                Console.WriteLine();
  293.                Console.WriteLine("  - Se han repartido las cartas, piensa en una y recuerdala que tratare de adivinarla");
  294.                Console.WriteLine(); Console.WriteLine();
  295.                Console.WriteLine("-  POZO 1  -");
  296.                Console.WriteLine();
  297.  
  298.                try
  299.                {
  300.                    for (int i = 0; i < 7; i++)
  301.                        Console.WriteLine("Carta Nº: {0}", Mazo[i]);
  302.                    Console.WriteLine(); Console.WriteLine();
  303.                    Console.WriteLine("-  POZO 2  -");
  304.                    Console.WriteLine();
  305.  
  306.                    for (int i = 7; i < 14; i++)
  307.                        Console.WriteLine("Carta Nº: {0}", Mazo[i]);
  308.                    Console.WriteLine(); Console.WriteLine();
  309.                    Console.WriteLine("-  POZO 3  -");
  310.                    Console.WriteLine();
  311.  
  312.                    for (int i = 14; i < 21; i++)
  313.                        Console.WriteLine("Carta Nº: {0}", Mazo[i]);
  314.                    Console.WriteLine(); Console.WriteLine();
  315.  
  316.                    Console.Write("  - Tu carta elegida esta en el pozo numero: ");
  317.  
  318.                    int opc = int.Parse(Console.ReadLine());
  319.                    error = 1;
  320.  
  321.  
  322.                    switch (opc)
  323.                    {
  324.                        case 1:
  325.  
  326.                            f = 20;
  327.                            h = 0;
  328.                            g = 0;
  329.  
  330.                            for (int i = 7; i < 14; i++)
  331.                            {
  332.                                SegundaR[j] = Mazo[i];
  333.                                j++;
  334.                            }
  335.  
  336.                            for (int i = 0; i < 7; i++)
  337.                            {
  338.                                SegundaR[j] = Mazo[i];
  339.                                j++;
  340.                            }
  341.  
  342.                            for (int i = 14; i < 21; i++)
  343.                            {
  344.                                SegundaR[j] = Mazo[i];
  345.                                j++;
  346.                            }
  347.  
  348.                            for (int i = 0; i < 7; i++)
  349.                            {
  350.  
  351.                                Pozo1[i] = SegundaR[f];
  352.                                f--;
  353.  
  354.                                Pozo2[g] = SegundaR[f];
  355.                                f--;
  356.                                Pozo3[h] = SegundaR[f];
  357.  
  358.                                g++;
  359.                                h++;
  360.                                f--;
  361.  
  362.  
  363.                            }
  364.  
  365.  
  366.  
  367.  
  368.  
  369.                            Mostrar(Pozo1, Pozo2, Pozo3, 1);
  370.  
  371.                            break;
  372.  
  373.  
  374.                        case 2:
  375.                            f = 20;
  376.                            h = 0;
  377.                            g = 0;
  378.  
  379.                            for (int i = 14; i < 21; i++)
  380.                            {
  381.                                SegundaR[j] = Mazo[i];
  382.                                j++;
  383.                            }
  384.  
  385.  
  386.  
  387.  
  388.                            for (int i = 7; i < 14; i++)
  389.                            {
  390.                                SegundaR[j] = Mazo[i];
  391.                                j++;
  392.                            }
  393.  
  394.  
  395.  
  396.  
  397.                            for (int i = 0; i < 7; i++)
  398.                            {
  399.                                SegundaR[j] = Mazo[i];
  400.                                j++;
  401.                            }
  402.  
  403.  
  404.                            for (int i = 0; i < SegundaR.Length; i++)
  405.                            {
  406.                                Pozo1[i] = SegundaR[f];
  407.                                f--;
  408.                                Pozo2[g] = SegundaR[f];
  409.                                f--;
  410.                                Pozo3[h] = SegundaR[f];
  411.  
  412.                                g++;
  413.                                h++;
  414.                                f--;
  415.  
  416.  
  417.                            }
  418.  
  419.  
  420.  
  421.                            Mostrar(Pozo1, Pozo2, Pozo3, 2);
  422.                            break;
  423.  
  424.                        case 3:
  425.  
  426.  
  427.                            f = 20;
  428.                            h = 0;
  429.                            g = 0;
  430.  
  431.  
  432.  
  433.                            for (int i = 0; i < 7; i++)
  434.                            {
  435.                                SegundaR[j] = Mazo[i];
  436.                                j++;
  437.                            }
  438.  
  439.  
  440.                            for (int i = 14; i < 21; i++)
  441.                            {
  442.                                SegundaR[j] = Mazo[i];
  443.                                j++;
  444.                            }
  445.  
  446.                            for (int i = 7; i < 14; i++)
  447.                            {
  448.                                SegundaR[j] = Mazo[i];
  449.                                j++;
  450.                            }
  451.  
  452.                            for (int i = 0; i < SegundaR.Length; i++)
  453.                            {
  454.                                Pozo1[i] = SegundaR[f];
  455.                                f--;
  456.  
  457.                                Pozo2[g] = SegundaR[f];
  458.                                f--;
  459.                                Pozo3[h] = SegundaR[f];
  460.  
  461.                                g++;
  462.                                h++;
  463.                                f--;
  464.  
  465.  
  466.                            }
  467.  
  468.                            Mostrar(Pozo1, Pozo2, Pozo3, 3);
  469.                            break;
  470.  
  471.                        default:
  472.                            Console.Clear();
  473.                            Console.WriteLine();
  474.                            Console.WriteLine("  - NUMERO INCORRECTO, SON 3 POZOS SOLAMENTE xD");
  475.                            error = 0;
  476.                            Console.WriteLine();
  477.                            Console.WriteLine(" Presione una tecla para volver..");
  478.                            break;
  479.                    }
  480.                    Console.ReadKey();
  481.  
  482.  
  483.                }
  484.                catch
  485.                { }
  486.                } while (error == 0);
  487.  
  488.  
  489.  
  490.  
  491.        }
  492.    }
  493. }
  494.  
  495.  

[/spoiler]


En línea

Edu


Desconectado Desconectado

Mensajes: 1.082


Ex XXX-ZERO-XXX


Ver Perfil
Re: AYUDA y EJERCICIO - Truco de cartas en C#
« Respuesta #2 en: 19 Diciembre 2010, 15:28 pm »

Se me hizo larguisimo el post perdonen, pero nadie se ha animado, no entiendo porq xD, yo si fuera un gran programador como mucho de ustedes me gustaria hacer todos los ejercicios q me propongan, les doy la oportunidad de q repasen, practiquen, comprueben si saben o no, y de paso ayudarme y no quieren xD
Lo dejare al post, talvez dentro de 2 años se anima alguien xD
En línea

[D4N93R]
Wiki

Desconectado Desconectado

Mensajes: 1.646


My software never has bugs. Its just features!


Ver Perfil WWW
Re: AYUDA y EJERCICIO - Truco de cartas en C#
« Respuesta #3 en: 20 Diciembre 2010, 01:46 am »

Esta el post de retos en .Net, si te animas puedes postear ahí, en el primer post están las reglas. Está en el subforo de Ejercicios :)
En línea

Edu


Desconectado Desconectado

Mensajes: 1.082


Ex XXX-ZERO-XXX


Ver Perfil
Re: AYUDA y EJERCICIO - Truco de cartas en C#
« Respuesta #4 en: 21 Diciembre 2010, 18:32 pm »

Bueno pero como ves tambien es una ayuda, es decir estaria bueno q puedan completar o arreglar mi code para q funcione, no me vengan tampoco con lo de q nadie te va a hacer las cosas q tenes q estudiar y bla bla bla, porq ya esta planteada mi idea el error q tengo es lo q quiero si me pueden dar una mano, y este post recibio 280 visitas ya xD se ve q nadie se anima
En línea

Edu


Desconectado Desconectado

Mensajes: 1.082


Ex XXX-ZERO-XXX


Ver Perfil
Re: AYUDA y EJERCICIO - Truco de cartas en C#
« Respuesta #5 en: 22 Diciembre 2010, 20:44 pm »

Perdon [D4N93R] por el doble post y por el inconveniente anterior, pero queria decir que ya logre hacerlo por cuenta propia, solo q siento q no fui muy profesional codeando y por eso quisiera si pueden criticar mi code aca:

http://foro.elhacker.net/net/me_pueden_dar_consejos_para_optimizar_mi_code_c-t314679.0.html

Gracias!
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Generador de cartas
Programación Visual Basic
aaronduran2 8 4,095 Último mensaje 21 Octubre 2008, 18:01 pm
por el_c0c0
[Ejercicio] Aca tienen un ejercicio para practicar « 1 2 3 »
Programación Visual Basic
Dreamaker 20 15,729 Último mensaje 5 Septiembre 2010, 02:57 am
por TGa.
pregunta ejercicio java cartas « 1 2 »
Java
casidus 12 12,008 Último mensaje 23 Marzo 2012, 02:41 am
por ohuilapan
Juego de cartas llamado truco
Java
marcelogalarza 0 2,775 Último mensaje 25 Septiembre 2011, 02:47 am
por marcelogalarza
Ayuda con mazo de cartas!!
Java
Ruusa 1 3,043 Último mensaje 3 Julio 2020, 00:29 am
por Serapis
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines