Matrix
Matrix
BI-Dimensionales
EN PSEINT
INTRODUCCIÓN
Supóngase que se tiene la siguientes calificaciones
de los alumnos de programación de la UPS
1 2 3
1 S (1,1) B (1,2) E (1,3)
Matrices 3
Matriz desde el punto de vista matemático
Matrices 4
Vista conceptual de una matriz
Columna 0 Columna1 Columna2 Columna3
Fila 0
Fila 1
Fila 2
Matrices 6
Acceso a los elementos de una Matriz.
Continuación
Sea la matriz M[3][4] M[2][3]
M[0][0] Columna 0 Columna1 Columna2 Columna3
Fila 0
Fila 1
Fila 2
Matrices 7
Dimensionar y leer una matriz Cont.
El recorrido de la matriz “Matriz” para su lectura se
hace de la siguiente manera:
0 1 2 3 4 5
Matrices 9
Procesar una matriz
Ejemplo: Calcular el promedio de los elementos de una
matriz.
Inicio
var suma, promedio,i,j
dimensionar M[3][3]
Matrices 11
Declaración de una matriz en C
tipo NombreMatriz [ No. filas ][No. columnas];
Ejemplo:
int Tabla [ 3 ] [ 5 ];
No. de columnas
No. de filas
Nombre de la matriz
Tipo de la matriz
Matrices 12
Inicializar una matriz
Además de leer, escribir y procesar matrices, también podemos
inicializarlas con valores para evitar leerlos desde el teclado u otro
dispositivo de E/S.
La inicialización se hace como sigue:
int tabla[2][3]={{10,20,30},{40,50,60}};
Matrices 14
Codificación del ejemplo anterior
#include<stdio.h> For(f=0;f<FIL;f++){ /*Se realiza la suma*/
#include<conio.h> For(c=0;c<COL;c++){
#define FIL 10 suma=suma+M[f][f];
#define COL 10 }
}
Main() { For(f=0;f<FIL;f++){ /*Se escribe M*/
int f,c, M[FIL][COL]; For(c=0;c<COL;c++){
int suma=0; printf(“%d ”,M[f][c]);
Clrscr(); }
Printf(“Dame los valores”); printf(“\n”);
For(f=0;f<FIL;f++){ }
For(c=0;c<COL;c++){ Printf(“La suma de la
scanf(“%d”,&M[f][c]); diagonal es:%d”,suma);
} }
}
Matrices 15
Ejercicios
1.-Considere la siguiente declaración: char *mensajes[5]={“Excelente”,”Bien”,”Ok”,”A casa”};
¿Es correcto? Si, No ¿Porqué? ¿Cuál es la salida de la siguiente sentencia?
printf(“%s”,mensajes[0]);
2.-¿Cuál es la salida del siguiente segmento de programa?
char junk[4][4];
int i,k;
for(i=0;i<16;i++)
for(k=0;k<4;k++)
if (i % 2 ==0)
junk[i][k] = ‘ A ‘;
else
junk[i][k] = ‘B ‘;
Matrices 16
Ejercicios. Continuación
• 3. Escriba un algoritmo que lea una matriz de flotantes de dimensión 3 x 5 y a
continuación debería escribir la matriz recién leída.
• 4. Elabore un algoritmo para leer una matriz de 7x7.Calcular la suma de cada
renglón y almacenarla en un vector, la suma de cada columna y almacenarla en
otro vector.
• 5. Algoritmo para leer una matriz de 20 x 20, sumar las columnas e imprimir qué
columna tuvo la máxima suma y la suma de esa columna.
• 6. Algoritmo que asigne datos a una matriz de 10 x 10 con 1’s en la diagonal
principal y 0 en las demás posiciones.
Matrices 17
• 7. Algoritmo para leer una matriz de 6x8 y que almacenen
toda la matriz en un vector. Imprima el vector resultante.
• 8. Algoritmo para leer una matriz de 5x6 y que imprima
cuántos elementos almacenados en la matriz son 0 ,
cuántos son positivos y cuántos son negativos.
• 9. Los resultados de las últimas elecciones a alcalde en el
pueblo de Cacalotepec han sido los siguientes:
Distrito Condado A Condado B Condado C Condado D
1 194 48 206 45
2 180 20 320 16
3 221 90 140 20
4 432 50 821 14
5 820 61 Matrices 946 18 18
Ejercicio.
• 9. Continuación
a) Imprimir la tabla anterior con cabeceras.
b) Calcule e imprima el número total de votos recibidos por cada candidato y el
porcentaje total de votos emitidos. Así mismo visualizar el candidato más
votado.
c) Si algún candidato recibe más del 50% de los votos, el programa imprimirá un
mensaje declarándolo ganador.
d) Si ningún candidato recibe más del 50% de los votos, el programa deberá
imprimir el nombre de los dos candidatos más votados, que serán los que pasen
a la segunda ronda de las elecciones.
Matrices 19
Ejercicios
• 10. Supóngase que los cuadrados de un juego del gato, se
enumeran como en la figura adjunta y se leen los números
de 3 cuadros N1,N2,N3. Sean N1<N2<N3. Si los tres
cuadros así designados están en una línea, asígnele a la
variable LINEA = 1, de otra manera asígnele a LINEA=0.
¿Habría una manera más sencilla de enumerar los cuadros
a fin de simplificar la prueba?
1 2 3
4 5 6
7 8 9
Matrices 20
Mas Ejercicios 11
Matrices 21
Ejercicios 12
Matrices 22
Ejercicio 13
• Escribir un programa que pida un número n e imprima por pantalla
su tabla de sumar. Por ejemplo si el número fuera el 3 la tabla
debería ser:
Matrices 23
Ejercicio 14
Matrices 25
Ejercicio 16
Matrices 26
Ejercicio 17
Matrices 27
Cont.
Matrices 28
RESTA DE VECTORES
• Vector-resultantre[i]=vector1[i]-vector2[i]
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
MULTIPLICACIÓN DE VECTORES
• Vector-resultantre[i]=vector1[i]*vector2[i]
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
DIVISIÓN DE VECTORES
• Vector-resultantre[i]=vector1[i]/vector2[i]
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Trabajo en Clase
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
DEMO
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Bubble Sort
• Funciona revisando cada elemento de la lista que va a ser ordenada con
el siguiente, intercambiándolos de posición si están en el orden
equivocado.
• Es necesario revisar varias veces toda la lista hasta que no se necesiten
más intercambios, lo cual significa que la lista está ordenada.
• Este algoritmo obtiene su nombre de la forma con la que suben por la
lista los elementos durante los intercambios, como si fueran pequeñas
"burbujas". También es conocido como el método del intercambio
directo.
• Dado que solo usa comparaciones para operar elementos, se lo
considera un algoritmo de comparación, siendo uno de los más sencillo
de implementar.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Reglas para el algoritmo
Dado un vector a1, a2, a3, ... an
01 03
Comparar a1 con a2 Informar que en
e intercambiarlos si cada ciclo se
a1>a2 hizo algún
cambio
02 04
Seguir hasta que NO perder de
todo se haya vista ningún valor
comparado
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Quick start
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Color palette Hero
possible.
Accent
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Only use the themes provided
Always use the template themes. It ensures consistency and reduces editing time when
you share content between presentations.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Agenda slides
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Agenda
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Agenda
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Agenda
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Student images
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Instructor images
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Partner images
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Graphic slides
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Title goes here
Subtitle and subtext goes here.
01 03
Insert body text here Insert body text here
Insert body text here Insert body text here
Insert body text here Insert body text here
02 04
Insert body text here Insert body text here
Insert body text here Insert body text here
Insert body text here Insert body text here
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Title goes here
Subtitle and subtext goes here.
01 04
Title goes here Title goes here
Insert body text here, body text here, body Insert body text here, body text here, body
text here, body text here and here. text here, body text here and here.
02 05
Title goes here Title goes here
Insert body text here, body text here, body Insert body text here, body text here, body
text here, body text here and here. text here, body text here and here.
03 06
Title goes here Title goes here
Insert body text here, body text here, body Insert body text here, body text here, body
text here, body text here and here. text here, body text here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Our top priorities
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Three main points
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
4 points and icons
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
5 points and icons
Title goes here Title goes here
Insert body text here, Insert body text here,
body text here, body body text here, body
text here, and here. text here, and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Three main points
01
List item goes here
02
List item goes here
03
List item goes here
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
4 arrows and text
Main title goes here and here Main title goes here and here
• Bullet point goes here and here • Bullet point goes here and here
• Bullet point goes here and here • Bullet point goes here and here
• Bullet point goes here and here • Bullet point goes here and here
• Bullet point goes here and here • Bullet point goes here and here
Main title goes here and here Main title goes here and here
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
4 points and text
02 04
Insert body text here, Insert body text here,
body text here, body text body text here, body text
here, body text here, here, body text here,
body text here and here. body text here and here.
Title goes here Title goes here Title goes here Title goes here
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
4 arrows and text
Title goes here Title goes here Title goes here Title goes here
Body text goes Body text goes Body text goes Body text goes
here, body text here, body text here, body text here, body text
goes here, body goes here, body goes here, body goes here, body
text goes here, text goes here, text goes here, text goes here,
body text goes body text goes body text goes body text goes
here, and here. here, and here. here, and here. here, and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
4 squares and text
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
6 points and text
Title goes here Title goes here
Insert body text here, body text here, body text Insert body text here, body text here, body text
here, body text here, body text here, body text here, here, body text here, body text here, body text here,
and here. and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
4 blocks and text
Title goes here Title goes here Title goes here Title goes here
Insert body text here, Insert body text here, Insert body text here, Insert body text here,
body text here, body body text here, body body text here, body body text here, body
text here, body text text here, body text text here, body text text here, body text
here, body text here, here, body text here, here, body text here, here, body text here,
and here and here. and here and here. and here and here. and here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
4 points and text
Title goes here Title goes here Title goes here Title goes here
Insert body text here, body text Insert body text here, body text Insert body text here, body text Insert body text here, body text
here, body text here, body text here, body text here, body text here, body text here, body text here, body text here, body text
here, body text here, body text here, body text here, body text here, body text here, body text here, body text here, body text
here, and here and here. here, and here and here. here, and here and here. here, and here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Timeline option
Title goes here Title goes here Title goes here Title goes here Title goes here Title goes here
Insert body text here, Insert body text here, Insert body text here, Insert body text here, Insert body text here, Insert body text here,
body text here, body body text here, body body text here, body body text here, body body text here, body body text here, body
text here, body text text here, body text text here, body text text here, body text text here, body text text here, body text
here, body text here, here, body text here, here, body text here, here, body text here, here, body text here, here, body text here,
and here and here. and here and here. and here and here. and here and here. and here and here. and here and here.
01 02 03 04 05 06
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Timeline option
Title goes here Title goes here Title goes here Title goes here
Insert body text here, Insert body text here, Insert body text here, Insert body text here,
body text here, body body text here, body body text here, body body text here, body
text here, body text text here, body text text here, body text text here, body text
here, body text here, here, body text here, here, body text here, here, body text here,
and here and here. and here and here. and here and here. and here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Graphic slides
with photography
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
“You are never too
old to set another
goal or to dream
a new dream”
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Title goes here
Insert body text here, body text here, body text here,
body text here, body text here, body text here, body
text here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Title goes here
Insert body text here, body text here, body text here,
body text here, body text here, body text here, body
text here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Title goes here Title goes here
Insert body text here, Insert body text here,
body text here, body text body text here, body text
here, body text here, here, body text here,
body text here, body text body text here, body text
here, body text here, here, body text here,
body text here and here. body text here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Title goes here
Insert body text here, body text here, body text
here, body text here, body text here, body text here,
body text here, body text here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Title goes here Title goes here Title goes here
Insert body text here, body text here, Insert body text here, body text here, Insert body text here, body text here,
body text here, body text here, body body text here, body text here, body body text here, body text here, body
text here, body text here, body text text here, body text here, body text text here, body text here, body text
here, body text here and here. here, body text here and here. here, body text here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
4 photos and 4 points
Title goes here Title goes here Title goes here Title goes here
Insert body text here, body text Insert body text here, body text Insert body text here, body text Insert body text here, body text
here, body text here, body text here, body text here, body text here, body text here, body text here, body text here, body text
here, body text here, body text here, body text here, body text here, body text here, body text here, body text here, body text
here, and here and here. here, and here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
here, and here and here. here, and here and here.
Team slides
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Small team slide
Firstname Lastname Firstname Lastname
Position Title Here Position Title Here
Excerpt text goes here, excerpt text Excerpt text goes here, excerpt text
goes here, excerpt text goes here, goes here, excerpt text goes here,
excerpt text goes here, excerpt text excerpt text goes here, excerpt text
goes here, and here. goes here, and here.
Excerpt text goes here, excerpt text Excerpt text goes here, excerpt text
goes here, excerpt text goes here, goes here, excerpt text goes here,
excerpt text goes here, excerpt text excerpt text goes here, excerpt text
goes here, and here. goes here, and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Large team slide
Firstname Lastname Firstname Lastname Firstname Lastname Firstname Lastname Firstname Lastname Firstname Lastname
Position Title Here Position Title Here Position Title Here Position Title Here Position Title Here Position Title Here
Firstname Lastname Firstname Lastname Firstname Lastname Firstname Lastname Firstname Lastname Firstname Lastname
Position Title Here Position Title Here Position Title Here Position Title Here Position Title Here Position Title Here
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Video
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
“Right Click” arrow icon > Hyperlink > Edit Hyperlink > Enter Desired YouTube url > Delete this box after finished
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Charts and tables
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Bar charts
12
10
Series 1
8 Series 2
6 Series 3
Series 4
4
Series 5
2 Series 6
0
Category 1 Category 2 Category 3 Category 4
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Multiple charts
Title goes here Title goes here Title goes here Title goes here
Insert body text here, body text Insert body text here, body text Insert body text here, body text Insert body text here, body text
here, body text here, body text here, body text here, body text here, body text here, body text here, body text here, body text
here, body text here, body text here, body text here, body text here, body text here, body text here, body text here, body text
here and here. here and here. here and here. here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Horizontal bar chart and points
Category 4
Category 3
Category 2
Category 1
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Bar chart
Subtitle goes here
Category 4
Category 2
Category 1
0 1 2 3 4 5 6
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Pie chart slide
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Pie charts and text
Line Item 1 Line Item 2 Line Item 3 Line Item 4 Line Item 5
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Bullet and chart slide
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Chart slide
1st Qtr
2nd Qtr
3rd Qtr
4th Qtr
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Charts and call out points
20% 25%
30%
20%
15% Insert body text here, body text here, body
text here, body text here, here and here.
15%
12%
25% Insert body text here, body text here, body
text here, body text here, here and here.
here, body text here, body text here, body text here, body text
here and here. here and here.
65% Insert body text here, body text here, body
text here, body text here, here and here.
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Chart slide
4 Series 1
3 Series 2
2 Series 3
0
Category 1 Category 2 Category 3 Category 4
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Line charts
12
10
Series 1
8
Series 2
6 Series 3
Series 4
4
Series 5
2 Series 6
0
Category 1 Category 2 Category 3 Category 4
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Table slide
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Table slide
Header
Header
Header
Header
Header
Header
Header
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Table slide
Total
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
This is a sample
headline
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Chart Title
6
This is a sample 3
headline 2
0
Category 1 Category 2 Category 3 Category 4
Series 1 Series 2 Series 3 Series 4
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
50
45
40
35
30
This is a sample 25
20
headline 15
10
5
0
Q1
Q2
Q3
Q4
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Heading 1 Heading 2 Heading 3
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Event
Agenda/speaker/ Plan your event Event/event
presentation experience highlights
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Event
Recording Partnerships Course
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Technology
IoT Security Security threat
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Soft skills
Laptop/computer/ Employment/jobs/ Graduating
monitor internships student
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Quarterly reporting
Budget Centralized Events
Support
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Additional
Teacher Idea Education
Goal
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Protecting our information
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Protecting our information
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Resources
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
8 tips for better presentations
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
3 tips for distributing your presentations
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Additional resources
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential