ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

ARREGLOS


Enviado por   •  6 de Febrero de 2013  •  Informes  •  8.662 Palabras (35 Páginas)  •  374 Visitas

Página 1 de 35

ARREGLOS

Los arreglos permiten almacenar vectores y matrices. Los arreglos unidimensionales

Sirven para manejar vectores y los arreglos bidimensionales para matrices. Sin embargo, las matrices también se pueden almacenar mediante arreglos unidimensionales y por medio de apuntadores a apuntadores, temas que se verán en el capıtulo siguiente.

La palabra unidimensional no indica que se trata de vectores en espacios de dimensión uno; indica que su manejo se hace mediante un subíndice. El manejo de los arreglos bidimensionales se hace mediante dos sub-índices.

Un arreglo se caracteriza por ser una lista de numero finito de n. elementos del mismo tipo; almacenar los elementos del arreglo en memoria continua, tener un único nombre de variable que representa a todos elementos y estos se diferencian por un índice o subíndice, acceder de manera directa o aleatoria a los elementos individuales del arreglo, se clasifican en:

• UNIDIMENSIONALES: VECTORES OLISTAS

• BIDIMENSIONALES: TABLAS O MATRICES

• MULTIDIMENSIONALES

ARREGLOS UNIDIMENSIONALES (VECTORES OLISTAS)

ES UN CONJUNTO DE N. ELEMENTOS QUE CONTINUA EN UN VECTOR OLISTA. EJEMPLO:

Int b[5];

For(x=0;X<5;x++); {

Scanf (“%i”,&b[x]);

Printf(“\n); }

For(x=0; x<5; x++);

Printf(“\n %i”, b[x]);

ARREGLOS BIDIMENSIONALES

SON ESTRUCTURAS DE DATOS QUE AGRUPAN MUCHOS DATOS DEL MISMO TIPO, EN DONDE CADA ELEMENTO SE PUEDE TRABAJAR INDIVIDUALMENTE Y SE PUEDE CON UN MISMO NOMBRE. DECLARACION:

TIPO DE DATO, NOMBRE, MARIZ, [INDICE][SUB INDICE]

EJEMPLO:

Int [3][3];

For (x=0; x<3; x++){

For(y=0;y<3;y++)

Scanf(“%i”, & c[x][y]);

}

Char c[3][20];

Int x;

For(x=0;x<3;x++)

Scanf(“%s”,&c[x]);

Arreglo bidimensional para cadenas.

PROGRAMAS

Programa con menú de arreglo unidimensional captura, muestra, suma, promedia, copia arreglo, invierte arreglo, muestra mayor, muestra menor, busca un numero.

#include<conio.h>

#include<stdio.h>

#define p printf

#define s scanf

main()

{

int arre[5],opc,x,acum=0,arre2[5],may,men,bus,band,y;

float prom;

while(opc!=10)

{

p("\n 1-.capturar\n 2-.mostrar\n 3-.suma\n 4-.promedio\n 5-.copiar arreglo a2\n 6-.invertir arreglo\n 7-.mostrar mayor\n 8-.mostrar menor\n 9-. buscar numero\n 10-.salir "); s("%i",&opc);

switch(opc)

{

case 1: p("\n capturar ");

for(x=0;x<5;x++)

s("%i",&arre[x]);

break;

case 2: p("\n mostrar ");

for(x=0;x<5;x++)

p("\n %i",arre[x]);

break;

case 3: p("\n suma ");

for(x=0;x<5;x++)

acum=acum+arre[x];

p("\n %i",acum);

break;

case 4: p("\n promedio ");

prom=acum/5;

p("\n %.1f",prom);

break;

case 5: p("\n copiar arreglo ");

for(x=0;x<5;x++)

{

arre2[x]=arre[x];

p("\n %i\t%i",arre[x],arre2[x]);

}

break;

case 6: p("\n invertir arreglo");

y=0;

for(x=4;x>=0;x--)

{

arre2[y]=arre[x];

y++;

}

...

Descargar como (para miembros actualizados)  txt (14.3 Kb)  
Leer 34 páginas más »
Disponible sólo en Clubensayos.com