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

 

 


Tema destacado: Estamos en la red social de Mastodon


  Mostrar Temas
Páginas: [1]
1  Programación / Programación C/C++ / leer y mostrar matriz en c++ ayuda! en: 19 Marzo 2017, 17:39 pm
Código
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #define MAX_FILAS 5
  5. #define MAX_COLUMNAS 5
  6.  
  7. using namespace std;
  8. void leerMatriz(int matriz[MAX_FILAS][MAX_COLUMNAS],int *filas,int *columnas)
  9. {
  10.    cout<<"filas";
  11.    cin>>*filas;
  12.    cout<<"columnas";
  13.    cin>>*columnas;
  14.  
  15.    for (int i=0;i<*filas;i++)
  16.    {
  17.        for(int j=0;j<*columnas;j++)
  18.        {
  19.            cout<<"["<<i<<"]["<<j<<"]= ";
  20.            cin>>matriz[i][j];
  21.        }
  22.    }
  23. }
  24.  
  25. void mostrarMatriz(int matriz[MAX_FILAS][MAX_COLUMNAS],int filas,int columnas)
  26. {
  27.    for (int i=0;i<filas;i++)
  28.    {
  29.        for(int j=0;i<columnas;j++)
  30.        {
  31.            cout<<matriz[i][j]<<"\t";
  32.  
  33.        }
  34.        cout<<endl;
  35.  
  36.    }
  37. }
  38. int main()
  39. {
  40.    int matriz1[MAX_FILAS][MAX_COLUMNAS],filas1,columnas1;
  41.    leerMatriz(matriz1,&filas1,&columnas1);
  42.    mostrarMatriz(matriz1,filas1,columnas1);
  43.    cout << "Hello world!" << endl;
  44.    return 0;
  45. }
hola necesito ayuda con el siguiente programa es un programa para leer matrices y mostrarlas en pantalla el problema es que al leer la matriz no cambia de columna sigue en la columna 0 y me lee infinitos valores para las filas queria saber cual es el error
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines