Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://estructuradatos.wordpress.com/2007/12/19/mayor-y-menor-matriz/
- #include <iostream.h>
- #include <stdlib.h>
- #include <stdio.h>
- void MayorMenor (int matriz[20][20],int nivel);
- int matriz[20][20];
- main(){
- //int matriz[10][10];
- int i=0,j=0;
- int elemento = 0;
- int nivel=0;
- printf(“Ingresa el nivel de la matriz: “);
- scanf(“%d”,&nivel);
- //ingresar elementos
- printf(“\n”);
- for(i=0;i<nivel;i++){
- for(j=0;j<nivel;j++){
- printf(“Ingesa elemento[%d][%d]: “,i,j);
- scanf(“%d”,&elemento);
- matriz[i][j] = elemento;
- }
- }
- //presentar elementos
- printf(“\nMatriz ingresada fue: \n”);
- for(i=0;i<nivel;i++){
- for(j=0;j<nivel;j++){
- printf(“%d\t”,matriz[i][j]);
- }
- printf(“\n”);
- }
- //Presentar mayor y menor
- MayorMenor(matriz,nivel);
- system(“PAUSE”);
- return 0;
- }
- void MayorMenor (int matriz[20][20],int nivel)
- {
- int i = 0,j = 0;
- int mayor = matriz[0][0];
- int menor = matriz[0][0];
- int elemento = 0;
- for(i=0;i<nivel;i++){
- for(j=0;j<nivel;j++){
- elemento = matriz[i][j];
- if(elemento>mayor)
- {
- mayor=elemento;
- }
- if(elemento<menor)
- {
- menor=elemento;
- }
- }
- }
- printf(“\nElemnto mayor: %d”,mayor);
- printf(“\nElemnto menor: %d\n\n”,menor);
- }
- http://waldestrand.wordpress.com/2008/06/30/multiplicacion-de-dos-matrices-en-c/
- #include<stdio.h>
- #include<iostream.h>
- #include<conio.h>
- main()
- {
- float mat1[10][10],mat2[10][10],mul[10][10];
- int i, j, k, L,M,N;
- printf(“\t ESTE PROGRAMA MULTIPLICA DOS MATRICES”);
- printf(“\n Introduzca el numero de filas de la matriz 1:”);
- scanf(“%d”,&N);
- printf(“\n Introduzca el numero de columnas de la matriz 1 y filas de la matriz 2:”);
- scanf(“%d”,&M);
- printf(“\n Introduzca el numero de columnas de la matriz 2:”);
- scanf(“%d”,&L);
- // Solicitar y almacenar los valores de las matrices
- printf(“\n\t Introduzca los valores de la MATRIZ 1 \n”);
- for(i=0;i<N;i++)
- for(j=0;j<M;j++)
- {
- printf(“\n\t Mat1 [%d][%d]=”,i,j);
- scanf(“%f”,&mat1[i][j]);
- }
- printf(“\n\t Introduzca los valores de la MATRIZ 2 \n”);
- for(i=0;i<M;i++)
- for(j=0;j<L;j++)
- {
- printf(“\n\t Mat2 [%d][%d]=”,i,j);
- scanf(“%f”,&mat2[i][j]);
- }
- //Imprimir los valores de las matrices en forma de filas y columas
- printf(“\n\n\t Matriz 1\n”);
- for (i=0;i<N;i++)
- {
- printf(“\n\n\t”);
- for(j=0;j<M;j++)
- printf(“%12.2f”,mat1[i][j]);
- }
- printf(“\n\n\t Matriz 2\n”);
- for (i=0;i<M;i++)
- {
- printf(“\n\n\t”);
- for(j=0;j<L;j++)
- printf(“%12.2f”,mat2[i][j]);
- }
- //Realiza la multiplicación e imprime el resultado
- for(i=0;i<N;i++)
- for(j=0;j<L;j++)
- {
- mul[i][j]=0;
- for(k=0;k<M;k++)
- {
- mul[i][j]=(mul[i][j] +(mat1[i][k]*mat2[k][j]));
- }
- }
- //Ahora solo tienes que mostrar el re
Advertisement
Add Comment
Please, Sign In to add comment