Beruflich Dokumente
Kultur Dokumente
LABORATORIO N 13
ALGORITMOS
Grupo: B Ciclo: II
Requiere No
Criterio de Excelente Bueno Puntaje
mejora acept.
Evaluacin (5pts) (4pts) Logrado
(3pts) (0pts)
Desarrolla Diagrama
de flujo y Pseudocdigo
Conoce y utiliza y
desarrolla Macros.
Realiza y desarrolla
ejercicios VBA
Puntualidad, orden
Observaciones, y
conclusiones
I. OBJETIVOS:
1. Escribe algoritmos en la solucin de problemas.
II. SEGURIDAD:
Advertencia:
En este laboratorio est prohibida la manipulacin del hardware,
conexiones elctricas o de red; as como la ingestin de alimentos
o bebidas. No jugar durante el desarrollo de la sesin.
.
III. RECURSOS:
En este laboratorio cada alumno trabar con un equipo con Windows.
Los equipos deben contar con internet.
Microsoft Word
Microsoft Excel 2013.
V. FUNDAMENTO TEORICO.
1. Diagrama de flujo.
TABLA 1
VI. PROCEDIMIENTO:
Nota:
Las secciones en cursivas son demostrativas, pero sirven para que usted pueda instalar las herramientas de
desarrollo en un equipo externo.
INICIO
INICIO
nicio
1. Declarar variables num1, num2,
num3, promedio Declarar variables num1,
num2, num3, promedio
2. Pedir nota1, nota2, nota3
Calcular promedio:
promedio=(num1+num2+num3)/3
Promedio
FIN
Ejercicio 2.
Determinar la hipotenusa de un tringulo rectngulo. Desarrolle el algoritmo correspondiente.
a2 = b2 + c2 (a hipotenusa / b y c catetos)
INICIO
1. Declarar variables a, b, c
INICIO
2. Pedir cateto1
nicio
3. Guardar cateto1 en b
Declarar variables a, b, c
4. Pedir cateto2
5. Guardar cateto2 en c
Pedir cateto1
6. Calcular hipotenusa: a2 = b2 + c2
7. Escribir hipotenusa
Guardar cateto1 en b
FIN
Pedir cateto2
Guardar cateto2 en c
Calcular hipotenusa: a2 = b2 + c2
Hipotenusa
FIN
PARTE 2 MACROS
Nota: Los archivos con extensin *.xlsx de Excel no permiten almacenar macros,
para poder grabar macros es necesario almacenar el archivo con la extensin
*.xlsm como se indica en el tem anterior.
3
1
2 5
a. Grabacin de macros
Grabaremos una macro denominada Macro1 que coloque la palabra Mes en la
celda A1
Seleccione o active la Hoja 1
En la ficha Desarrollador en la categora Cdigo elija la herramienta: Grabar
Macro
A partir de este momento Excel Grabar cada una de las acciones que usted
realice
Proceda a ingresar la palabra Mes en la celda A1. Al finalizar presione la tecla
ENTER
Ahora procederemos a detener la grabacin de la Macro anterior, para ello presione
el botn denominado Detener grabacin ubicado en la categora Cdigo de la
ficha Desarrollador:
Repita el procedimiento anterior para que la macro coloque el texto Mes en la celda
A1 de la Hoja 3
c. Visualizar el cdigo de la macro creada
Vamos a visualizar el cdigo VBA generado por Excel para la macro Macro1 que
hemos creado en la seccin anterior
Desde cualquier etiqueta, utilizando la ficha Desarrollador, en la categora Cdigo
elija la herramienta Visual Basic.
O cerrando la ventana.
Crear y ubicarse en una nueva etiqueta (Hoja5) e ingresar dos valores al azar en las
celdas A1 y A2.
Ejecutar la macro creada y comprobar su funcionamiento.
Visualice el cdigo generado para la nueva Macro y anote dicho cdigo.
Sub Macro2()
'
' Macro2 Macro
' No
'
'
Range("A4").Select
ActiveCell.FormulaR1C1 = "19%"
Range("B2").Select
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
ActiveCell.FormulaR1C1 = "=(R[-1]C[-1]+RC[-1])*R[2]C[-1]"
Range("B2").Select
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
End Sub
Sub Macro3()
'
' Macro3 Macro
' m_titulos
'
'
Range("A2").Select
ActiveCell.FormulaR1C1 = "Nro"
ActiveCell.FormulaR1C1 = "Nro"
Range("B2").Select
ActiveCell.FormulaR1C1 = "Nombre"
Range("C2").Select
ActiveCell.FormulaR1C1 = "DNI"
Range("D2").Select
ActiveCell.FormulaR1C1 = "Sexo"
Range("E2").Select
ActiveCell.FormulaR1C1 = "Fecha de"
Range("E3").Select
ActiveCell.FormulaR1C1 = "Nacimiento "
Range("E2").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("E3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
PROGRAMA DE FORMACIN REGULAR
Nro. DD-106
ALGORITMOS Y PSEUDOCDIGO - LABORATORIO 13
INFORMTICA APLICADA Pgina 10 de 20
Range("A2:A3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A2:A3").Select
Selection.Copy
Range("B2:E3").Select
Range("A2:A3").Select
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Range("B2:D3").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("D5").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("B2:D3").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
Range("A2:E3").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
PROGRAMA DE FORMACIN REGULAR
Nro. DD-106
ALGORITMOS Y PSEUDOCDIGO - LABORATORIO 13
INFORMTICA APLICADA Pgina 11 de 20
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("B2:B3").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("C2:C3").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
PROGRAMA DE FORMACIN REGULAR
Nro. DD-106
ALGORITMOS Y PSEUDOCDIGO - LABORATORIO 13
INFORMTICA APLICADA Pgina 12 de 20
Range("D2:D3").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("E2:E3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A2:E3").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
PROGRAMA DE FORMACIN REGULAR
Nro. DD-106
ALGORITMOS Y PSEUDOCDIGO - LABORATORIO 13
INFORMTICA APLICADA Pgina 13 de 20
.PatternTintAndShade = 0
End With
Range("A2:E3").Select
Range("E3").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
Range("D7").Select
End Sub
Sub Macro4()
'
' Macro4 Macro
' m_grafico
'
'
Application.WindowState = xlMaximized
Range("A2:B14").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData Source:=Range("Hoja8!$A$2:$B$14")
ActiveChart.PlotArea.Select
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("1 Grfico").IncrementLeft -122.25
ActiveSheet.Shapes("1 Grfico").IncrementTop -25.5
ActiveSheet.Shapes("1 Grfico").IncrementLeft -12
ActiveSheet.Shapes("1 Grfico").IncrementTop -12
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 4
ActiveChart.ClearToMatchStyle
ActiveChart.ApplyLayout (6)
Range("J8").Select
ActiveSheet.ChartObjects("1 Grfico").Activate
ActiveChart.Axes(xlCategory).Select
ActiveChart.ApplyLayout (8)
ActiveChart.ApplyLayout (10)
PROGRAMA DE FORMACIN REGULAR
Nro. DD-106
ALGORITMOS Y PSEUDOCDIGO - LABORATORIO 13
INFORMTICA APLICADA Pgina 15 de 20
ActiveChart.ChartType = xlCylinderCol
Range("K15").Select
ActiveSheet.ChartObjects("1 Grfico").Activate
ActiveChart.PlotArea.Select
ActiveChart.ChartType = xl3DColumn
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 43
ActiveChart.ClearToMatchStyle
Range("K11").Select
End Sub
Nota: Hemos creado el procedimiento con nombre Sumarceldas que permite sumar dos valores
especficos. Observar que el procedimiento empieza con el mensaje Sub y termina con el
mensaje End Sub.
ENTER
k. Dibujamos un botn cuadrado que ser el botn para la suma. Seleccionamos el botn,
clic en propiedades.
m. Damos doble clic en el botn de suma, nos mostrar plataforma VBA Libro1. En la
ventana de cmdsuma, escribimos sumarceldas. Luego damos doble clic a
Operacionesmatemticas
1
n. Repetimos la operacin para la resta.
2
Nota: Esta instruccin indica que al hacer doble clic en el botn creado, queremos utilizar
el procedimiento sumarceldas, creado en el mdulo Operacionesmatemticas.
o. Damos clic en (B5) y seleccionamos la opcin Play.
p. Regresamos a Excel
q. En las celdas B2 y B3 insertamos dos valores al azar, damos clic en el botn suma y
comprobamos la suma.
r. Para detener la accin, estando en Excel nos dirigimos a VBA y seleccionamos la
opcin de pausa o detencin.
PROGRAMA DE FORMACIN REGULAR
Nro. DD-106
ALGORITMOS Y PSEUDOCDIGO - LABORATORIO 13
INFORMTICA APLICADA Pgina 18 de 20
CONCLUSIONES
En conclusin diramos que el algoritmo es de carcter general y puede aplicarse a cualquier operacin matemtica o a
cualquier problema.
La formulacin de algoritmos fue uno de los ms grandes adelantos dentro de la ciencia matemtica ya que a partir de
ellos se pudieron resolver infinidad de problemas.
Los Algoritmos son una manera de expresar cualquier situacin por medio de una secuencia de pasos ordenados y
lgicos que buscan el aclaramiento de cualquier problema para as identificar lo que se necesita, como se hace y el
resultado final, el cual debe ser igual siempre por lo que se busca que hayan alternativas para cualquier solucin posible.
Los diagramas de flujo son la representacin grfica de un algoritmo y tiene como finalidad lograr una mayor
comprensin de este. Est compuesto por diversos smbolos que especifican las diversas partes del algoritmo, como los
componentes iniciales, los procedimientos, las diversas posibilidades y los resultados.
OBSERVACIONES:
Se utilizan smbolos que representan cada paso de los algoritmos.
Es importante conservar los diagramas de flujo lo ms sencillo posible, y apoyarse en el significado de la simbologa.
Por ello, debemos evitar escribir demasiado texto dentro de cada uno de los smbolos, y en su lugar, utilizar slo el
identificador de la variable y las expresiones aritmticas, relacionales o lgicas segn sea el caso.
Para un buen estilo de diseo del algoritmo, y en general, para ayudar la traduccin posterior al lenguaje de
programacin deseado, es necesario conservar la verticalidad del diagrama, sin inventar conexiones diferentes a las
establecidas.
Es muy importante utilizar los smbolos adecuados para cada operacin a realizar. De esta forma, en el smbolo
condicional, no deben incluirse asignaciones; ni en el smbolo de proceso se pueden incluir operadores relacionales ni
lgicos.
Se expresa mediante frmulas matemticas que determinarn las salidas del problema.
Se utiliza el lenguaje natural ya sea hablado o escrito. Por ejemplo, la receta para hacer un pastel.