[01][02][03][04]
[08][07][06][05]
[09][10][11][12]
#include<stdio.h>
#include<conio.h>
void llenar (int M[20][20], int f, int c)
{
int k=1;
for (int i=1;i<=f;i++)
{
if (i%2!=0)
{
for (int j=1;j<=c;j++)
{
M[i][j]=k; k++;
}
}
else
{
for (int j=c;j>=1;j--)
{
M[i][j]=k; k++;
}
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i=1;i<=f;i++)
{
printf("\n");
for (int j=1;j<=c;j++)
{
printf("[%d] ",M[i][j]);
}
}
}
int main ()
{
int f, c;
int M[20][20];
printf("Inserte filas de M: "); scanf("%d",&f);
printf("Inserte cols. de M: "); scanf("%d",&c);
llenar(M, f, c);
mostrar(M, f, c);
getch();
}
#include<conio.h>
void llenar (int M[20][20], int f, int c)
{
int k=1;
for (int i=1;i<=f;i++)
{
if (i%2!=0)
{
for (int j=1;j<=c;j++)
{
M[i][j]=k; k++;
}
}
else
{
for (int j=c;j>=1;j--)
{
M[i][j]=k; k++;
}
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i=1;i<=f;i++)
{
printf("\n");
for (int j=1;j<=c;j++)
{
printf("[%d] ",M[i][j]);
}
}
}
int main ()
{
int f, c;
int M[20][20];
printf("Inserte filas de M: "); scanf("%d",&f);
printf("Inserte cols. de M: "); scanf("%d",&c);
llenar(M, f, c);
mostrar(M, f, c);
getch();
}
Generar la matriz:
[01][02][03][04]
[05][06][07][00]
[08][09][00][00]
[10][00][00][00]
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int d)
{
int cont=1;
for (int i=1;i<=d;i++)
{
for (int j=1;j<=d;j++)
{
if ((i+j)<=(d+1))
{M[i][j]=cont; cont++;}
else
M[i][j]=0;
}
}
}
void mostrar (int M[20][20], int d)
{
for (int i=1;i<=d;i++)
{
printf("\n");
for (int j=1;j<=d;j++)
{
printf ("[%d] ",M[i][j]);
}
}
}
int main ()
{
int d;
int M[20][20];
printf("Insert dimen: "); scanf("%d",&d);
llenar(M, d);
mostrar(M, d);
getch();
}
#include <conio.h>
void llenar (int M[20][20], int d)
{
int cont=1;
for (int i=1;i<=d;i++)
{
for (int j=1;j<=d;j++)
{
if ((i+j)<=(d+1))
{M[i][j]=cont; cont++;}
else
M[i][j]=0;
}
}
}
void mostrar (int M[20][20], int d)
{
for (int i=1;i<=d;i++)
{
printf("\n");
for (int j=1;j<=d;j++)
{
printf ("[%d] ",M[i][j]);
}
}
}
int main ()
{
int d;
int M[20][20];
printf("Insert dimen: "); scanf("%d",&d);
llenar(M, d);
mostrar(M, d);
getch();
}
Dadas dos matrices A y B intercambiar los minimos de A con los maximos de B
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M[i][j]);
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M[i][j]);
}
}
}
int menor (int M[20][20], int f, int c)
{
int men = M [1] [1];
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
if (M [i] [j] < men)
men = M [i] [j];
}
}
return (men);
}
int maximo (int M[20][20], int f, int c)
{
int max = M [1] [1];
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
if (M [i] [j] > max)
max = M [i] [j];
}
}
return (max);
}
void intercambiar (int A[20][20], int fa, int ca, int B[20][20], int fb, int cb)
{
int min_a = menor (A, fa, ca);
int max_b = maximo (B, fb, cb);
//para cambiar los minimos de A con los maximos de B
for (int i = 1 ; i <= fa ; i++)
{
for (int j = 1 ; j <= ca ; j++)
{
if (A[i][j] == min_a)
A[i][j]=max_b;
}
}
//para intercambiar los maximos de con los minimos de A
for (int i = 1 ; i <= fb ; i++)
{
for (int j = 1 ; j <= cb ; j++)
{
if (B[i][j] == max_b)
B[i][j]=min_a;
}
}
}
int main ()
{
int A [20] [20];
int B [20] [20];
int fa, ca, fb, cb;
printf ("Insert filas de A: "); scanf("%d",&fa);
printf ("Insert columnas de A: "); scanf("%d",&ca);
printf ("Insert filas de B: "); scanf("%d",&fb);
printf ("Insert columnas de B: "); scanf("%d",&cb);
//lectura de matrices
printf ("\nINSERTANDO DATOS EN MATRIS A: \n");
llenar (A, fa, ca);
printf ("\nINSERTANDO DATOS EN MATRIS B: \n");
llenar (B, fb, cb);
printf ("\nMATRICES ORIGINALMENTE INSERTADAS: ");
mostrar (A, fa, ca);
printf ("\n");
mostrar (B, fb, cb);
printf ("\n");
//intercambiando elementos
intercambiar (A, fa, ca, B, fb, cb);
printf ("\nMATRICES DESPUES DEL INTERCAMBIO:");
mostrar (A, fa, ca);
printf ("\n");
mostrar (B, fb, cb);
getch();
}
#include <conio.h>
void llenar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M[i][j]);
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M[i][j]);
}
}
}
int menor (int M[20][20], int f, int c)
{
int men = M [1] [1];
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
if (M [i] [j] < men)
men = M [i] [j];
}
}
return (men);
}
int maximo (int M[20][20], int f, int c)
{
int max = M [1] [1];
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
if (M [i] [j] > max)
max = M [i] [j];
}
}
return (max);
}
void intercambiar (int A[20][20], int fa, int ca, int B[20][20], int fb, int cb)
{
int min_a = menor (A, fa, ca);
int max_b = maximo (B, fb, cb);
//para cambiar los minimos de A con los maximos de B
for (int i = 1 ; i <= fa ; i++)
{
for (int j = 1 ; j <= ca ; j++)
{
if (A[i][j] == min_a)
A[i][j]=max_b;
}
}
//para intercambiar los maximos de con los minimos de A
for (int i = 1 ; i <= fb ; i++)
{
for (int j = 1 ; j <= cb ; j++)
{
if (B[i][j] == max_b)
B[i][j]=min_a;
}
}
}
int main ()
{
int A [20] [20];
int B [20] [20];
int fa, ca, fb, cb;
printf ("Insert filas de A: "); scanf("%d",&fa);
printf ("Insert columnas de A: "); scanf("%d",&ca);
printf ("Insert filas de B: "); scanf("%d",&fb);
printf ("Insert columnas de B: "); scanf("%d",&cb);
//lectura de matrices
printf ("\nINSERTANDO DATOS EN MATRIS A: \n");
llenar (A, fa, ca);
printf ("\nINSERTANDO DATOS EN MATRIS B: \n");
llenar (B, fb, cb);
printf ("\nMATRICES ORIGINALMENTE INSERTADAS: ");
mostrar (A, fa, ca);
printf ("\n");
mostrar (B, fb, cb);
printf ("\n");
//intercambiando elementos
intercambiar (A, fa, ca, B, fb, cb);
printf ("\nMATRICES DESPUES DEL INTERCAMBIO:");
mostrar (A, fa, ca);
printf ("\n");
mostrar (B, fb, cb);
getch();
}
Dada una matris cuadrada invertir su diagonal principal
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
for (int j = 1 ; j <= d ; j++)
{
printf ("Inserte pos[%d][%d]: ",i, j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
printf("\n");
for (int j = 1 ; j <= d ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void invierte (int M[20][20], int d)
{
int fin = d;
for (int i = 1 ; i <= d / 2 ; i++)
{
int aux = M [i] [i];
M [i] [i] = M [d] [d];
M [d] [d] = aux;
fin--;
}
}
int main()
{
int M [20] [20];
int d;
printf ("Inserte dimen. de la matris cuadrada: ");
scanf("%d",&d);
llenar (M, d);
printf ("\nMATRIS ORIGINAL: ");
mostrar (M, d);
printf ("\n\nMATRIS CON LA DIAGONAL PRINCIPAL INVERTIDA: ");
invierte (M, d);
mostrar (M, d);
getch();
}
#include <conio.h>
void llenar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
for (int j = 1 ; j <= d ; j++)
{
printf ("Inserte pos[%d][%d]: ",i, j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
printf("\n");
for (int j = 1 ; j <= d ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void invierte (int M[20][20], int d)
{
int fin = d;
for (int i = 1 ; i <= d / 2 ; i++)
{
int aux = M [i] [i];
M [i] [i] = M [d] [d];
M [d] [d] = aux;
fin--;
}
}
int main()
{
int M [20] [20];
int d;
printf ("Inserte dimen. de la matris cuadrada: ");
scanf("%d",&d);
llenar (M, d);
printf ("\nMATRIS ORIGINAL: ");
mostrar (M, d);
printf ("\n\nMATRIS CON LA DIAGONAL PRINCIPAL INVERTIDA: ");
invierte (M, d);
mostrar (M, d);
getch();
}
Dada una matris cuadrada invertir su diagonal secundaria
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
for (int j = 1 ; j <= d ; j++)
{
printf ("Inserte pos[%d][%d]: ",i, j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
printf("\n");
for (int j = 1 ; j <= d ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void invierte (int M[20][20], int d)
{
int fin = d;
for (int i = 1 ; i <= d / 2 ; i++)
{
int aux = M [i] [d];
M [i] [d] = M [d] [i];
M [d] [i] = aux;
fin--;
}
}
int main()
{
int M [20] [20];
int d;
printf ("Inserte dimen. de la matris cuadrada: ");
scanf("%d",&d);
llenar (M, d);
printf ("\nMATRIS ORIGINAL: ");
mostrar (M, d);
printf ("\n\nMATRIS CON LA DIAGONAL SECUNDARIA INVERTIDA: ");
invierte (M, d);
mostrar (M, d);
getch();
}
#include <conio.h>
void llenar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
for (int j = 1 ; j <= d ; j++)
{
printf ("Inserte pos[%d][%d]: ",i, j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
printf("\n");
for (int j = 1 ; j <= d ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void invierte (int M[20][20], int d)
{
int fin = d;
for (int i = 1 ; i <= d / 2 ; i++)
{
int aux = M [i] [d];
M [i] [d] = M [d] [i];
M [d] [i] = aux;
fin--;
}
}
int main()
{
int M [20] [20];
int d;
printf ("Inserte dimen. de la matris cuadrada: ");
scanf("%d",&d);
llenar (M, d);
printf ("\nMATRIS ORIGINAL: ");
mostrar (M, d);
printf ("\n\nMATRIS CON LA DIAGONAL SECUNDARIA INVERTIDA: ");
invierte (M, d);
mostrar (M, d);
getch();
}
Dada dos matrices de diferentes tamanios R y S mostrar los elementos comunes de R en S
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void comunes (int R[20][20], int fr, int cr, int S[20][20], int fs, int cs)
{
printf("\n\nLos elementos comunes de R en S son: ");
for (int i = 1 ; i <= fr ; i++)
{
for (int j = 1 ; j <= cr ; j++)
{
for (int k = 1 ; k <= fs ; k++)
{
for (int l = 1 ; l <= cs ; l++)
{
if (R [i] [j] == S [k] [l])
printf ("[%d]",R [i] [j]);
}
}
}
}
}
int main()
{
int R [20] [20];
int S [20] [20];
int fr, cr, fs, cs;
printf("Inserte filas de R: ");
scanf("%d",&fr);
printf("Inserte columnas de R: ");
scanf("%d",&cr);
printf("Inserte filas de S: ");
scanf("%d",&fs);
printf("Inserte columnas de S: ");
scanf("%d",&cs);
printf("\nLLENANDO MATRIS R: \n");
llenar (R, fr, cr);
printf("\nLLENANDO MATRIS S: \n");
llenar (S, fs, cs);
printf("\nLA MATRIS R : ");
mostrar (R, fr, cr);
printf("\n\nLA MATRIS S : ");
mostrar (S, fs, cs);
comunes (R, fr, cr, S, fs, cs);
getch();
}
#include <conio.h>
void llenar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void comunes (int R[20][20], int fr, int cr, int S[20][20], int fs, int cs)
{
printf("\n\nLos elementos comunes de R en S son: ");
for (int i = 1 ; i <= fr ; i++)
{
for (int j = 1 ; j <= cr ; j++)
{
for (int k = 1 ; k <= fs ; k++)
{
for (int l = 1 ; l <= cs ; l++)
{
if (R [i] [j] == S [k] [l])
printf ("[%d]",R [i] [j]);
}
}
}
}
}
int main()
{
int R [20] [20];
int S [20] [20];
int fr, cr, fs, cs;
printf("Inserte filas de R: ");
scanf("%d",&fr);
printf("Inserte columnas de R: ");
scanf("%d",&cr);
printf("Inserte filas de S: ");
scanf("%d",&fs);
printf("Inserte columnas de S: ");
scanf("%d",&cs);
printf("\nLLENANDO MATRIS R: \n");
llenar (R, fr, cr);
printf("\nLLENANDO MATRIS S: \n");
llenar (S, fs, cs);
printf("\nLA MATRIS R : ");
mostrar (R, fr, cr);
printf("\n\nLA MATRIS S : ");
mostrar (S, fs, cs);
comunes (R, fr, cr, S, fs, cs);
getch();
}
Intercambiar los datos de la columna 1 con la ultima columna
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos:[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void intercambiar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
int aux = M [i] [1];
M [i] [1] = M [i] [c];
M [i] [c] = aux;
}
}
int main ()
{
int M [20] [20];
int f, c;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS : \n");
llenar (M, f, c);
printf ("\nLA MATRIS ORIGINAL : ");
mostrar (M, f, c);
printf ("\n\nLA MATRICES INTERCAMBIADA : ");
intercambiar (M, f, c);
mostrar (M, f, c);
getch();
}
#include <conio.h>
void llenar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos:[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void intercambiar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
int aux = M [i] [1];
M [i] [1] = M [i] [c];
M [i] [c] = aux;
}
}
int main ()
{
int M [20] [20];
int f, c;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS : \n");
llenar (M, f, c);
printf ("\nLA MATRIS ORIGINAL : ");
mostrar (M, f, c);
printf ("\n\nLA MATRICES INTERCAMBIADA : ");
intercambiar (M, f, c);
mostrar (M, f, c);
getch();
}
Contar el numero de digitos de cada elemento de una matris
#include <stdio.h>
#include <conio.h>
void llenar (int M [20] [20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M [20] [20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void cuenta (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
int contador = 0;
int n=M[i][j];
while (n != 0)
{
n = n / 10;
contador++;
}
printf("\n[%d] tiene: %d digito(s)",M[i][j],contador);
}
}
}
int main ()
{
int M [20] [20];
int f, c;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS M: \n");
llenar (M, f, c);
printf ("\nLA MATRIS: ");
mostrar (M, f, c);
printf ("\n\nCONTEO DE DIGITOS: ");
cuenta (M, f, c);
getch();
}
#include <conio.h>
void llenar (int M [20] [20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M [20] [20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void cuenta (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
int contador = 0;
int n=M[i][j];
while (n != 0)
{
n = n / 10;
contador++;
}
printf("\n[%d] tiene: %d digito(s)",M[i][j],contador);
}
}
}
int main ()
{
int M [20] [20];
int f, c;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS M: \n");
llenar (M, f, c);
printf ("\nLA MATRIS: ");
mostrar (M, f, c);
printf ("\n\nCONTEO DE DIGITOS: ");
cuenta (M, f, c);
getch();
}
Hallar la fila y la columna del primer elemento "e"
#include <stdio.h>
#include <conio.h>
void llenarMatris (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrarMatris (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf ("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j] );
}
}
}
void busqueda (int M[20][20], int f, int c, int e)
{
int bn = 0;
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
if (M [i] [j] == e)
{
printf("\nEl numero: %d se encuentra en la posicion: [%d][%d] de la matris",e, i, j);
bn = 1;
}
}
}
if (bn == 0)
printf("\nNo se encontro el numero %d en la matris :(",e);
}
int main ()
{
int M [20] [20];
int f, c, numero;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS: \n");
llenarMatris (M, f, c);
printf ("\nLA MATRIZ Z: ");
mostrarMatris (M, f, c);
printf ("\n\nInserte un numero: ");
scanf("%d",&numero);
busqueda (M, f, c, numero);
getch();
}
#include <conio.h>
void llenarMatris (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrarMatris (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
printf ("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j] );
}
}
}
void busqueda (int M[20][20], int f, int c, int e)
{
int bn = 0;
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
if (M [i] [j] == e)
{
printf("\nEl numero: %d se encuentra en la posicion: [%d][%d] de la matris",e, i, j);
bn = 1;
}
}
}
if (bn == 0)
printf("\nNo se encontro el numero %d en la matris :(",e);
}
int main ()
{
int M [20] [20];
int f, c, numero;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS: \n");
llenarMatris (M, f, c);
printf ("\nLA MATRIZ Z: ");
mostrarMatris (M, f, c);
printf ("\n\nInserte un numero: ");
scanf("%d",&numero);
busqueda (M, f, c, numero);
getch();
}
0 Comentarios