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

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Duda sonre array en zigzag
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Duda sonre array en zigzag  (Leído 1,348 veces)
vladi89

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Duda sonre array en zigzag
« en: 19 Enero 2016, 18:52 pm »

[NOTA DEL MODERADOR]
1. Usa las etiquetas GeShi para isnertar código.
2. Publica las preguntas de programación en el subforo correspondiente.
Lee las reglas del foro.



Buenas a todos, aunque no sé si este tema iria aquí.

tengo una duda sobre un programa que imprima una matriz en zig zag así

Código:
1 10 11 20
2 9  12 19
3 8  13 18
4 7  14 17
5 6  15 16

de momento tengo esto pero estoy bloqueado, no se como darle la vuelta cada vez que llegue al final de una columna

Código
  1. const int kfila = 3;
  2.        const int kcolumna = 3;
  3.  
  4.        int[,] matriz = new int[kfila, kcolumna];
  5.  
  6.  
  7.  
  8.        void leermatriz(int[,] matriz)
  9.        {
  10.            int i, j;
  11.  
  12.            for (i = 0; i < matriz.GetLength(0); i++)
  13.                for (j = 0; j < matriz.GetLength(1); j++)
  14.                    matriz[i, j] = int.Parse(InputBox("elemento[" + i + " , " + j + "]"));
  15.        }
  16.        string mostrarmatriz(int[,] matriz)
  17.        {
  18.            int i, j;
  19.            string texto;
  20.            texto = "Los valores de la matriz son:\n";
  21.  
  22.            for (j = 0; j < matriz.GetLength(1); j++)
  23.            {
  24.  
  25.                for (i = 0; i < matriz.GetLength(0); i++)
  26.                    for (i = matriz.GetLength(0) - 1; i >= 0; i--)
  27.                        texto = texto + matriz[i, j] + ", ";
  28.                texto = texto + "\n"; // Retorno de carro al terminar cada fila
  29.            }
  30.            return texto;
  31.        }

Solo pido saber como le doy la vuelta para que continue en la columna siguiente, un saludo. y gracias


« Última modificación: 19 Enero 2016, 19:53 pm por Eleкtro » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Duda con array
Java
anman 4 2,987 Último mensaje 2 Abril 2008, 22:29 pm
por Lu15_CL4
duda de array
Programación C/C++
mapers 1 2,246 Último mensaje 6 Septiembre 2010, 15:48 pm
por darkraider
Duda con array
Java
~ Yoya ~ 0 1,500 Último mensaje 13 Marzo 2011, 21:18 pm
por ~ Yoya ~
Duda con los array C++
Programación C/C++
seryioo 1 1,630 Último mensaje 8 Agosto 2015, 21:46 pm
por Orubatosu
duda array [c++]
Programación C/C++
dbr69 5 1,825 Último mensaje 15 Enero 2016, 12:42 pm
por dbr69
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines