Arreglos hg 15 set
-
Upload
hugogomezch -
Category
Documents
-
view
292 -
download
0
Transcript of Arreglos hg 15 set
![Page 1: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/1.jpg)
![Page 2: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/2.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 2
“Año de la Integración Nacional y el Reconocimiento de Nuestra Diversidad”
INSTITUTO SUPERIOR TECNOLÓGICO
IDAT
TEMA :ARREGLOS
CURSO :LENGUAJE DE PROGRAMACION
ESPECIALIDAD : COMPUTACION E INFORMATICA
PROFESOR :JULIO ALFREDO,CÓRDOVA FORERO
INTEGRANTE :HUGO,GOMEZ CHICO
CICLO : II
TURNO : NOCHE
![Page 3: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/3.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 3
IDAT
2012
LENGUAJE DE PROGRAMACION
ARREGLOS
![Page 4: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/4.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 4
Visual Basic . NET
ARREGLOS UNIDIMENSIONALES
Un Array(arreglo) o vector es una estructura que
permite almacenar un conjunto de elementos o datos de un
mismo tipo de datos.
Un Arreglo se declara mediante el nombre del arreglo, el tamaño o
numero de elementos y el tipo de dato.
Para acceder a cada elemento del arreglo se utiliza un índice que
identifica la posición de dicho elemento. El primer elemento se
identifica con el índice 0, el segundo elemento con el índice 1 y así
sucesivamente.
En Visual Basic .NET : Dim Pares(5) As Integer
ARREGLOS UNIDIMENSIONALES
Para acceder a cada elemento del arreglo y almacenar el respectivo
valor, se hace de la siguiente manera:
40 28 4 16 32 12 PARES (5)
0 1 2 3 4 5
![Page 5: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/5.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 5
40 28 4 16 32 12 PARES (5)
0 1 2 3 4 5
ARREGLOS UNIDIMENSIONALES Para leer el arreglo por teclado usando un InputBox:
Dim Pares(5) As Integer
Pares(0)=40
Pares(1)=28
Pares(2)=4
Pares(3)=16
Pares(4)=32
Pares(5)=12
For i=0 to 5
Pares( i ) = InputBox(“Digite numero par : “) Next
Para obtener un valor del arreglo: Dim Par as integer Par = Pares(3) En la variable Par quedara almacenado el numero 16.
![Page 6: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/6.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 6
40 28 4 16 32 12 PARES (5)
0 1 2 3 4 5
40 28 4 16 32 12 PARES (5)
0 1 2 3 4 5
ARREGLOS UNIDIMENSIONALES
Para recorrer todo el arreglo e imprimirlo:
Dim Pares(5) As Integer
Pares(0)=40
Pares(1)=28
Pares(2)=4
Pares(3)=16
Pares(4)=32
Pares(5)=12
Imprimiendo el arreglo: For i=0 to 5
MsgBox( Pares(i) ) Next
![Page 7: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/7.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 7
ARREGLOS MULTIDIMENSIONALES
Son aquellos que constan de 2 o mas dimensiones. Los arreglos de 2
dimensiones también se conocen con el nombre de matriz, ya que
forman una tabla compuesta por filas (Horizontales) y columnas
(verticales). Los arreglos de 3 dimensiones forman un cubo.
COLUMNAS
FILAS
1 0 2
0
1
2
3
Dim Pares (3,2) As Integer
![Page 8: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/8.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 8
Para almacenar datos en cada elemento de la matriz:
Declaramos Matriz:
Dimempleados(3,1)As String
Almacenamos valores:
empleados(0,0) = “Hugo";
empleados(0,1) = “Lunes";
empleados(1,0) = “Jose";
empleados(1,1) = “Martes";
empleados(2,0) = “Antonio";
empleados(2,1) = “Miércoles";
empleados(3,0) = “Angelica";
empleados(3,1) = “Jueves";
1 0
0
1
2
3
ARREGLOS MULTIDIMENSIONALES
Hugo Lunes
Jose Martes
Antonio Miércoles
Angelica Jueves
![Page 9: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/9.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 9
1 0
0
1
2
3
ARREGLOS MULTIDIMENSIONALES
Hugo Lunes
Jose Martes
Antonio Miércoles
Angelica Jueves
Para llenar matriz desde teclado usando InputBox:
Declaramos Matriz:
Dimempleados (3,1)As String
Almacenamos valores:
Forfila = 0 To3
Forcolumna = 0To1
empleados(fila,columna) = InputBox(“Digite información: “)
Next
Next
![Page 10: Arreglos hg 15 set](https://reader035.fdocuments.ec/reader035/viewer/2022081813/5598f53c1a28ab64278b45b3/html5/thumbnails/10.jpg)
LENGUAJE DE PROGRAMACIÓN
Pág 10
ARREGLOS MULTIDIMENSIONALES
Para imprimir una matriz usando un TextBox Multiline:
Public Class Form1
Dim matriz(,) As Integer = {{1, 2, 3, 4}, {5, 6, 7, 8}} ‘ Inicializacion del arreglo bidimensional
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
For i = 0 To 1
For j = 0 To 3
TextBox1.Text = TextBox1.Text & matriz(i, j) & “ “ ‘ Escribiendo en el TextBox
Next
TextBox1.Text = TextBox1.Text & vbCrLf ‘ vbCrLf SALTO DE LINEA
Next
End Sub
End Class