1 / 7

VECTORES

VECTORES. Definición de Variable. MEMORIA DE LA COMPUTADORA. 15. Hacer X = 15. Significa que en la dirección de memoria N° 22 se encuentra almacenado el valor 15. Cada variable ocupa SOLO UN ESPACIO de memoria. ARREGLOS.

sage-booth
Télécharger la présentation

VECTORES

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VECTORES

  2. Definición de Variable MEMORIA DE LA COMPUTADORA 15 Hacer X = 15 Significa que en la dirección de memoria N° 22 se encuentra almacenado el valor 15. Cada variable ocupa SOLO UN ESPACIO de memoria

  3. ARREGLOS • Es un conjunto de celdas de memoria de direcciones CONSECUTIVAS donde se almacenan valores del mismo tipo. • Cada una de las celdas individuales se denomina término del arreglo. Está asociada a un único nombre de variable llamado Nombre del arreglo y a uno o más subíndicesnuméricos que identifica/n su posición dentro del mismo. A cada juego de subíndices le corresponde un valor. • La cantidad máxima de elementos que puede tener un arreglo constituye el tamaño del arregloy debe ser especificado por el programador. • La cantidad de subíndices que tiene un arreglo se denomina dimensión. • Si el arreglo posee un solo subíndice se denomina VECTOR. Si posee dos se denomina LISTA o MATRIZ. • Se dice que un arreglo tiene n DIMENSIONES. • Nos referiremos únicamente a los VECTORES.

  4. VECTORES MEMORIA DE LA COMPUTADORA a es el nombre del vector y se utiliza para todos los términos del mismo. El vector a tiene 26 términos y el programador deberá declararlo como a[ 26 ] a[ 0 ] (primer término) a[ 25 ] (último término) a[ 7 ]

  5. PROGRAMACIÓN CON VECTORES Lenguaje C int a[25]; int n; a[0] = 30; a[24] = 62; a[1] = a[24]; n = 23; a[n] = a[0] + a[1]; Seudocódigo Dimensionar a[25] hacer a[0] = 30 hacer a[24] = 62 hacer a[1] = a[24] n = 23 hacer a[n] = a[0] + a[1]

  6. Programa de ejemplo. Ingesar a un vector 50 números enteros consecutivos a partir del 100 y luego mostrar los términos pares en forma ascendente y descendente • Dimensionar vct[50] • hacer i = 0 • mientras ( i < 50 ) • hacer vct[ i ] = i + 100 • hacer i = i + 1 • fin mientras • para i = 0 hasta 49 salto 2 • Mostrar vct[ i ] • Mostrar vct[48 – i] • fin para • #include <stdio.h> • void main() • { • int vct[50]; • int i; • for( i=0; i<50;i++ ) • vct[i] = i + 100; • for( i=0; i<50;i+=2 ) • printf( “%d\t%d\n”, • vct[i], vct[48-i]); • }

  7. FIN

More Related