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

 

 


Tema destacado: Curso de javascript por TickTack


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Ayuda con matrices
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda con matrices  (Leído 2,488 veces)
sheccid65

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Ayuda con matrices
« en: 6 Febrero 2010, 19:44 pm »

Estoy haciendo una matriz que simula el juego del triqui o tres en raya, ya está todo resuelto, pero a la hora de validar que si un jugador marca por ejemplo la casilla 1, el jugador 2 no lo peda hacer... yo lo validé con un si y le mando un mensaje q la casilla está ocupada, pero el mensaje se queda ahi y en las jugadas sgts sigue apareciendo, te mando el codigo donde hago esa parte

For i = 1 To 9
            If i Mod 2 <> 0 Then
                WriteAt("jugador  1 ", 2, 13)
                h = Console.ReadLine
                WriteAt(" ", 13, 13)
                While m(1, 1) = 2 Or m(1, 2) = 2 Or m(1, 3) = 2 Or m(2, 1) = 2 Or m(2, 2) = 2 Or m(2, 3) = 2 Or m(3, 1) = 2 Or m(3, 2) = 2 Or m(3, 2) = 2
                    WriteAt("Esta posicion se encuentra ocupada", 4, 15)
                    WriteAt(" por favor juegue de nuevo  ", 5, 15)
                    ' Console.ReadLine()
                    h = Console.ReadLine
                    WriteAt(" ", 13, 13)
                    WriteAt("                                          ", 4, 15)
                    WriteAt("                                          ", 5, 15)
                End While

                If h = 1 Then
                    m(1, 1) = 1
                    a = 3
                    b = 1
                    WriteAt("X", a, b)
                End If
                If h = 2 Then
                    m(1, 2) = 1
                    a = 10
                    b = 1
                    WriteAt("X", a, b)
                End If
                If h = 3 Then
                    m(1, 3) = 1
                    a = 17
                    b = 1
                    WriteAt("X", a, b)
                End If
                If h = 4 Then
                    m(2, 1) = 1
                    a = 3
                    b = 5
                    WriteAt("X", a, b)
                End If
                If h = 5 Then
                    m(2, 2) = 1
                    a = 10
                    b = 5
                    WriteAt("X", a, b)
                End If
                If h = 6 Then
                    m(2, 3) = 1
                    a = 17
                    b = 5
                    WriteAt("X", a, b)
                End If
                If h = 7 Then
                    m(3, 1) = 1
                    a = 3
                    b = 8
                    WriteAt("X", a, b)
                End If
                If h = 8 Then
                    m(3, 2) = 1
                    a = 10
                    b = 8
                    WriteAt("X", a, b)
                End If
                If h = 9 Then
                    m(3, 3) = 1
                    a = 17
                    b = 8
                    WriteAt("X", a, b)
                End If

            Else
                WriteAt("jugador  2 ", 2, 13)
                h = Console.ReadLine
                WriteAt(" ", 13, 13)
                While m(1, 1) = 1 Or m(1, 2) = 1 Or m(1, 3) = 1 Or m(2, 1) = 1 Or m(2, 2) = 1 Or m(2, 3) = 1 Or m(3, 1) = 1 Or m(3, 2) = 1 Or m(3, 2) = 1
                    WriteAt("Esta posicion se encuentra ocupada", 4, 15)
                    WriteAt(" por favor juegue de nuevo  ", 5, 15)
                    ' Console.ReadLine()
                    h = Console.ReadLine
                    WriteAt(" ", 13, 13)
                    WriteAt("                                          ", 4, 15)
                    WriteAt("                                          ", 5, 15)

                End While

                If h = 1 Then
                    m(1, 1) = 2

                    a = 3
                    b = 1
                    WriteAt("O", a, b)
                End If
                If h = 2 Then
                    m(1, 2) = 2
                    a = 10
                    b = 1
                    WriteAt("O", a, b)
                End If
                If h = 3 Then
                    m(1, 3) = 2
                    a = 17
                    b = 1
                    WriteAt("O", a, b)
                End If
                If h = 4 Then
                    m(2, 1) = 2
                    a = 3
                    b = 5
                    WriteAt("O", a, b)
                End If
                If h = 5 Then
                    m(2, 2) = 2
                    a = 10
                    b = 5
                    WriteAt("O", a, b)
                End If
                If h = 6 Then
                    m(2, 3) = 2
                    a = 17
                    b = 5
                    WriteAt("O", a, b)
                End If
                If h = 7 Then
                    m(3, 1) = 2
                    a = 3
                    b = 8
                    WriteAt("O", a, b)
                End If
                If h = 8 Then
                    m(3, 2) = 2
                    a = 10
                    b = 8
                    WriteAt("O", a, b)
                End If
                If h = 9 Then
                    m(3, 3) = 2
                    a = 17
                    b = 8
                    WriteAt("O", a, b)
                End If


            End If

Agradezco su ayuda.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Ayuda con matrices y como recorrerlas
Programación Visual Basic
frekency 3 2,345 Último mensaje 10 Diciembre 2010, 23:35 pm
por ignorantev1.1
Ayuda.Ejercicio de matrices! en C
Programación C/C++
sofi1 3 2,960 Último mensaje 22 Agosto 2011, 00:13 am
por sofi1
ayuda en matrices c# !!
.NET (C#, VB.NET, ASP)
jcac12 1 6,180 Último mensaje 13 Noviembre 2011, 18:02 pm
por Morringos
Ayuda en C: Funciones y Matrices
Programación C/C++
outlookk 5 3,165 Último mensaje 5 Febrero 2013, 15:09 pm
por outlookk
ayuda con codigo de matrices
.NET (C#, VB.NET, ASP)
Nidrogg 2 2,101 Último mensaje 26 Octubre 2014, 05:00 am
por Eleкtro
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines