Advertisement
joaquinflorespalao

MATRIZ

May 28th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5.  
  6. using namespace std;
  7.  
  8. void CreandoMatriz(short** &M, short &Filas, short &Columnas) {
  9. cout << "Creando matriz...\n";
  10. cout << "Ingrese filas: "; cin >> Filas;
  11. cout << "Ingrese columnas: "; cin >> Columnas;
  12. M = new short*[Filas];
  13. for (short fila = 0; fila < Filas; fila++)
  14. M[fila] = new short[Columnas];
  15. }
  16.  
  17. void IngresarValores(short** M, short Filas, short Columnas) {
  18. cout << "Ingresando valores...\n";
  19. for (short fila = 0; fila < Filas; fila++) {
  20. for (short columna = 0; columna < Columnas; columna++) {
  21. cout << "M[" << fila << "]" << "[" << columna << "]: ";
  22. cin >> M[fila][columna];
  23. }
  24. }
  25. }
  26. void MostrarValores(short** M, short Filas, short Columnas) {
  27. cout << "Mostrando valores...\n";
  28. for (short fila = 0; fila < Filas; fila++) {
  29. for (short columna = 0; columna < Columnas; columna++) {
  30. cout <<M[fila][columna];
  31. }cout << endl;
  32. }
  33. }
  34.  
  35. void Limpiar_memoria(short** M, short Filas) {
  36.  
  37. for (short fila = 0; fila < Filas; fila++) {
  38. delete[] M[fila];
  39. }
  40. delete[] M;
  41.  
  42. }
  43.  
  44. int main()
  45. {
  46. short **M, Filas, Columnas;
  47.  
  48.  
  49. CreandoMatriz(M, Filas, Columnas);
  50. cout << endl;
  51. IngresarValores(M, Filas, Columnas);
  52. cout << endl;
  53. system("pause>null");
  54. MostrarValores(M, Filas, Columnas);
  55. system("pause>null");
  56. Limpiar_memoria(M, Filas);
  57. system("pause>null");
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement