Un apuntador es una variable que solamente almacena direcciones de memoria, se llama apuntador, pointer o puntero, por que a traves de esa variable, se puede llegar a otra variable, para que se pueda definir un apuntador, debe ser del mismo tipo a la variable que va a apuntar, por ejemplo
int clave, y quiero declarar un apuntador que apunte a esta variable se declara con el mismo tipo
int *ptr.
Cuando se declara una variable, se le dice al compilador a traves del sistema operativo que resrve un espacio de memoria y le asigne un nombre.
.
miércoles, 25 de septiembre de 2013
lunes, 23 de septiembre de 2013
Resolucion de Examen
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
void main(void)
{
int temo=0, 1, num[6];
int *ptr;
for (i=0; i <= 5; i++)
{temp = temp +5-i;
num[i] = temp;}
ptr = &num[0];
for (i = 0; i <= 5; i++)
{printf("\n %d, %p", num[i], ptr);
ptr++;}
ptr = &num[0];
}
Diagramas en el cuaderno e.e
Estatus de la evaluacion, ir pensando en recursar o en el extra
#include <iostream.h>
#include <conio.h>
void main(void)
{
int temo=0, 1, num[6];
int *ptr;
for (i=0; i <= 5; i++)
{temp = temp +5-i;
num[i] = temp;}
ptr = &num[0];
for (i = 0; i <= 5; i++)
{printf("\n %d, %p", num[i], ptr);
ptr++;}
ptr = &num[0];
}
Diagramas en el cuaderno e.e
Estatus de la evaluacion, ir pensando en recursar o en el extra
lunes, 9 de septiembre de 2013
Programa de Lista
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <ctype.h>
#include <stdlib.h>
struct lista {
int clave;
char descrip[25];
struct lista *sigptr; };
typedef struct lista LISTA;
typedef LISTA *LSTPTR;
void enlista(LSTPTR *iniptr, LSTPTR *finptr, int cla, char descr[25])
{ LSTPTR nvoptr, actptr, otroptr;
nvoptr = (LSTPTR) malloc(sizeof(LISTA));
if (nvoptr != NULL)
{nvoptr->clave = cla;
strcpy(nvoptr->descrip, descr);
nvoptr->sigptr = NULL;
if (*iniptr == NULL)
{*iniptr = nvoptr;
*finptr = nvoptr;
}
else
{actptr = *iniptr;
if (cla < (*iniptr)->clave)
{nvoptr->sigptr = *iniptr;
*iniptr = nvoptr;
}
else
if (cla > (*finptr)->clave)
{(*finptr)->sigptr = nvoptr;
*finptr = nvoptr;
}
else
{otroptr = actptr->sigptr;
while (cla > otroptr->clave)
{actptr= actptr->sigptr;
otroptr= actptr->sigptr;
}
actptr->sigptr = nvoptr;
nvoptr->sigptr = otroptr;
}
}
}
else
printf("%d no fue insertado. No hay memoria disponible\n\n", cla);
}
void menu(void)
{ system("cls");
printf("\n\n\n\n"
" OPERACIONES DISPONIBLES EN LA LISTA ORDENADA: \n\n\n\n"
" 1 AGREGAR UN ELEMENTO A LA LISTA\n"
" 2 IMPRIMIR LA LISTA\n"
" 3 EXTRAER UN ELEMENTO DE LA LISTA\n"
" 4 SALIR DEL PROGRAMA\n");
}
main()
{ LSTPTR iniptr = NULL, finptr = NULL;
char opcion, descri[25];
int clav;
menu();
printf("\n Elige opcion: ");
scanf("%c", &opcion);
while (opcion != '4')
{ switch(opcion)
{ case '1': printf("\n Clave del articulo (entero): ");
scanf("%d", &clav);
fflush(stdin);
printf("\n Descripcion del articulo : ");
gets(descri);
enlista(&iniptr, &finptr, clav, descri) ;
break;
default : printf("\n\n Opcion no valida.....");
printf("\n\n Enter para continuar...");
getch();
break;
}
menu();
fflush(stdin);
printf("\n Elige opcion: ");
scanf("%c", &opcion);
}
printf("\n Fin del programa.\n\n");
printf(" Enter para terminar...");
getch();
}
miércoles, 28 de agosto de 2013
Filas o Colas
FiFo
first in first out
si se compara una fila, se tiene un aountador que esta apuntando al tope de esa fila, y entre sus nodos se crean enlases, y el primero que entro a la pila, es nulo, y de esa manera se van haciendo los enlances, en la cola, vamos a suponer que se tiene estos nodos que se van a encolar,
first in first out
si se compara una fila, se tiene un aountador que esta apuntando al tope de esa fila, y entre sus nodos se crean enlases, y el primero que entro a la pila, es nulo, y de esa manera se van haciendo los enlances, en la cola, vamos a suponer que se tiene estos nodos que se van a encolar,
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
struct colanodo {
int clave;
char descrip[20];
struct colanodo *sigptr;};
typedef struct colanodo COLANODO;
typedef COLANODO *COLANODOPTR;
void enqueue(COLANODOPTR *, COLANODOPTR *, int, char[]);
void menu(void);
main()
{ COLANODOPTR adelaptr = NULL, atrasptr = NULL;
int opcion, clav;
char descri[20];
menu();
printf("\n Elige opcion: ");
scanf("%d", &opcion);
while (opcion != 4)
{ switch(opcion)
{ case 1: printf("\n INSERCION EN LA COLA");
printf("\n\n Clave del articulo: ");
scanf("%d", &clav);
fflush(stdin);
printf("\n Descripcion del articulo: ");
gets(descri);
enqueue(&adelaptr, &atrasptr, clav, descri);
break;
default : printf("\n Opcion no permitida.\n\n");
printf(" Enter para continuar...");
getch();
menu();
break;
}
menu();
printf("\n Elige opcion: ");
scanf("%d", &opcion);
}
printf("\n Fin del programa.\n\n");
printf("\n Enter para salir...");
getch();
}
void menu(void)
{ system("cls");
printf("\n\n\n\n"
" OPERACIONES DISPONIBLES CON LA COLA: \n\n\n\n"
" 1 (enqueue) AGREGAR UN DATO A LA COLA\n"
" 2 (dequeue) ELIMINAR UN DATO DE LA COLA\n"
" 3 IMPRIMIR LA COLA\n"
" 4 SALIR DEL PROGRAMA\n");
}
void enqueue(COLANODOPTR *adelaptr, COLANODOPTR *atrasptr, int cla, char desc[20])
{ COLANODOPTR nvoptr;
nvoptr = (COLANODOPTR) malloc(sizeof(COLANODO));
if (nvoptr != NULL) {
nvoptr->clave = cla;
strcpy(nvoptr->descrip, desc);
nvoptr->sigptr = NULL;
if (*adelaptr==NULL)
*adelaptr = nvoptr;
else
(*atrasptr)->sigptr = nvoptr;
*atrasptr = nvoptr;
}
else
printf("%c %s no fue insertado. No hay memoria disponible\n\n", cla, desc);
}
lunes, 26 de agosto de 2013
Pila, a medias, no lo acabe -.-
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
struct pilanodo {
int clave;
char descrip[20];
struct pilanodo *sigptr;
};
typedef struct pilanodo PILANODO;//redefinicion pila
typedef PILANODO *PILANODOPTR;//redefinicion apuntador
void push(PILANODOPTR *, int, char[]);
void instrucciones(void);
void listar(PILANODOPTR);
main()
{ PILANODOPTR pilaptr = NULL;
int opcion, cve;
char desc[20];
instrucciones();
printf("\n Elige opcion: ");
scanf("%d", &opcion);
while (opcion != 4)
{ switch(opcion)
{ case 1: printf("\n Escribe la clave del articulo (entero): ");
scanf("%d", &cve);
fflush(stdin);
printf("\n Escribe la descripcon del articulo: ");
gets(desc);
push(&pilaptr, cve, desc);//direccion de pilaptr(&pilaptr)
break;
case 3: listar(pilaptr);
break;
default : printf("\n Opcion no permitida. \n\n");
printf("\n Enter para continuar...");
getch();
instrucciones();
}
instrucciones();
printf("\n Elige opcion: ");
scanf("%d", &opcion);
}
printf("\n Fin del programa.\n\n");
printf(" Enter para salir...");
getch();
}
void push(PILANODOPTR *topeptr, int cve, char des[20])// *topeptr apunta a pilaptr
{ PILANODOPTR nuevoptr;//como no se va a modificar no se pone *
nuevoptr = (PILANODOPTR) malloc(sizeof(PILANODO));
if (nuevoptr != NULL)
{ nuevoptr->clave = cve;
strcpy(nuevoptr->descrip, des);
nuevoptr->sigptr = *topeptr;//en estas 2 lineas se intercambian los valores del apyuntador
*topeptr = nuevoptr;
}
else
{ printf("\n %d %s, no fue insertado."
"\n No hay memoria disponible. \n", cve, des);
printf("\n Enter para continuar...");
getch();
}
}
void listar (PILANODOPTR auxptr)
{
if(auxptr==NULL)
printf("\n\n La pila esta vacia");
else
{while(auxptr->sigptr!=NULL)
{
printf("\n %d%s",auxptr->clave,auxptr->descrip);
auxptr=auxptr->sigptr;
}
}
}
void instrucciones(void)
{ system("cls");
printf(" \n\n\n\n"
" OPERACIONES DISPONIBLES CON LA PILA: \n\n\n\n"
" 1 (push) INSERTAR UN VALOR EN LA PILA \n"
" 2 (pop) EXTRAER UN VALOR DE LA PILA \n"
" 3 IMPRIMIR LA PILA \n"
" 4 SALIR DEL PROGRAMA \n");
}
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
struct pilanodo {
int clave;
char descrip[20];
struct pilanodo *sigptr;
};
typedef struct pilanodo PILANODO;//redefinicion pila
typedef PILANODO *PILANODOPTR;//redefinicion apuntador
void push(PILANODOPTR *, int, char[]);
void instrucciones(void);
void listar(PILANODOPTR);
main()
{ PILANODOPTR pilaptr = NULL;
int opcion, cve;
char desc[20];
instrucciones();
printf("\n Elige opcion: ");
scanf("%d", &opcion);
while (opcion != 4)
{ switch(opcion)
{ case 1: printf("\n Escribe la clave del articulo (entero): ");
scanf("%d", &cve);
fflush(stdin);
printf("\n Escribe la descripcon del articulo: ");
gets(desc);
push(&pilaptr, cve, desc);//direccion de pilaptr(&pilaptr)
break;
case 3: listar(pilaptr);
break;
default : printf("\n Opcion no permitida. \n\n");
printf("\n Enter para continuar...");
getch();
instrucciones();
}
instrucciones();
printf("\n Elige opcion: ");
scanf("%d", &opcion);
}
printf("\n Fin del programa.\n\n");
printf(" Enter para salir...");
getch();
}
void push(PILANODOPTR *topeptr, int cve, char des[20])// *topeptr apunta a pilaptr
{ PILANODOPTR nuevoptr;//como no se va a modificar no se pone *
nuevoptr = (PILANODOPTR) malloc(sizeof(PILANODO));
if (nuevoptr != NULL)
{ nuevoptr->clave = cve;
strcpy(nuevoptr->descrip, des);
nuevoptr->sigptr = *topeptr;//en estas 2 lineas se intercambian los valores del apyuntador
*topeptr = nuevoptr;
}
else
{ printf("\n %d %s, no fue insertado."
"\n No hay memoria disponible. \n", cve, des);
printf("\n Enter para continuar...");
getch();
}
}
void listar (PILANODOPTR auxptr)
{
if(auxptr==NULL)
printf("\n\n La pila esta vacia");
else
{while(auxptr->sigptr!=NULL)
{
printf("\n %d%s",auxptr->clave,auxptr->descrip);
auxptr=auxptr->sigptr;
}
}
}
void instrucciones(void)
{ system("cls");
printf(" \n\n\n\n"
" OPERACIONES DISPONIBLES CON LA PILA: \n\n\n\n"
" 1 (push) INSERTAR UN VALOR EN LA PILA \n"
" 2 (pop) EXTRAER UN VALOR DE LA PILA \n"
" 3 IMPRIMIR LA PILA \n"
" 4 SALIR DEL PROGRAMA \n");
}
Pilas
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
struct pilanodo {
int clave;
char descrip[20];
struct pilanodo *sigptr;
};
typedef struct pilanodo PILANODO;
typedef PILANODO *PILANODOPTR;
void push(PILANODOPTR *, int, char[]);
void instrucciones(void);
main()
{ PILANODOPTR pilaptr = NULL;
int opcion, cve;
char desc[20];
instrucciones();
printf("\n Elige opcion: ");
scanf("%d", &opcion);
while (opcion != 4)
{ switch(opcion)
{ case 1: printf("\n Escribe la clave del articulo (entero): ");
scanf("%d", &cve);
fflush(stdin);
printf("\n Escribe la descripcon del articulo: ");
gets(desc);
push(&pilaptr, cve, desc);
break;
default : printf("\n Opcion no permitida. \n\n");
printf("\n Enter para continuar...");
getch();
instrucciones();
}
instrucciones();
printf("\n Elige opcion: ");
scanf("%d", &opcion);
}
printf("\n Fin del programa.\n\n");
printf(" Enter para salir...");
getch();
}
void push(PILANODOPTR *topeptr, int cve, char des[20])
{ PILANODOPTR nuevoptr;
nuevoptr = (PILANODOPTR) malloc(sizeof(PILANODO));
if (nuevoptr != NULL)
{ nuevoptr->clave = cve;
strcpy(nuevoptr->descrip, des);
nuevoptr->sigptr = *topeptr;
*topeptr = nuevoptr;
}
else
{ printf("\n %d %s, no fue insertado."
"\n No hay memoria disponible. \n", cve, des);
printf("\n Enter para continuar...");
getch();
}
}
void instrucciones(void)
{ system("cls");
printf(" \n\n\n\n"
" OPERACIONES DISPONIBLES CON LA PILA: \n\n\n\n"
" 1 (push) INSERTAR UN VALOR EN LA PILA \n"
" 2 (pop) EXTRAER UN VALOR DE LA PILA \n"
" 3 IMPRIMIR LA PILA \n"
" 4 SALIR DEL PROGRAMA \n");
}
miércoles, 21 de agosto de 2013
Pilas
Las pilas son un conjunto ordenado de objetos o nodos, los cuales pueden trabajarse uno a la ves, se llaman pilas por que los nodos se van apilando. Las pilas se trabajan bajo el concepto conocido como LIFO(Last in First out)
definimos una estructura de datos tipo pila
struct pilanodo
{int dato;
struct pilamodo * sigptr;
}
typedef struct pilanodo PILANODO;
typedef PILANODO *PILANODOPTR;
PILANODO var;
struct pilanodo *ptr;
PILANODO *PTR;
PILANODOPTR *pilaptr;
pilaptr = NULL
if(pilaptr==NULL)
PILANODOPTR *nuevoptr;
if (nuevoptr = (PILANODOPTR) malloc (sizeof(PILANODO)))
------------------------------------------------
main() | pilaptr=NULL |
| -Incersion |
| -palabra que no entendi por la |
| letra del profe -.- |
------------------------------------------------
definimos una estructura de datos tipo pila
struct pilanodo
{int dato;
struct pilamodo * sigptr;
}
typedef struct pilanodo PILANODO;
typedef PILANODO *PILANODOPTR;
PILANODO var;
struct pilanodo *ptr;
PILANODO *PTR;
PILANODOPTR *pilaptr;
pilaptr = NULL
if(pilaptr==NULL)
PILANODOPTR *nuevoptr;
if (nuevoptr = (PILANODOPTR) malloc (sizeof(PILANODO)))
------------------------------------------------
main() | pilaptr=NULL |
| -Incersion |
| -palabra que no entendi por la |
| letra del profe -.- |
------------------------------------------------
martes, 20 de agosto de 2013
Apuntadores y valor de las variables
Cuando en programacion uno asigna un valor a una variable, depende del tipo de variable el espacio en memoria que va a ocupar asi como tmabien depende de la arquitectura, para probar esto en el siguiente programa vamos a asignar valores a 2 variables y por medio de un apuntador vamos a mostrar el espacio en memoria que ocupa con lo que nos mostrara a partir de que bloque de memoria alamcena la variable. En este caso al ser enteros vemos que el almacenamiento es cada 4 bytes.
#include<stdio.h> #include<conio.h> main () { int x,y; int *ptr; x=5; y=10; ptr= &x; printf ("\n\n\n Valor: %i : Localizacion:%p", *ptr,ptr); printf ("\n\n\n Valor: %i : Localizacion:%p", x,&x); ptr= &y; printf ("\n\n\n Valor: %i : Localizacion:%p", y,&y); printf ("\n\n\n Valor: %i : Localizacion:%p", y,&y); getch (); return 0; } lunes, 19 de agosto de 2013
//Programa que captura las horas y las temperaturas, al final las despliega #include <stdio.h> #include <conio.h> main() { int horas[24],x; printf("Este programa al macna las temperaturas de las 24 horas de un dias \n\n"); for (x=0;x<=23;x++) { printf("\nDeme la temperatura de la hora %i\n", x); scanf("%i",&horas[x]); } for (x=0;x<=23;x++) printf("\n La temperatura de la hora %i es %i", x,horas[x]); getch (); return 0; } Programa Suma de Matrices
//Programa que captura los datos de 2 matrices y los suma en una tercera
#include <stdio.h>
#include <conio.h>
main()
{
int matrix1[3][3],matrix2[3][3],matrix3[3][3],x,y;
for (x=0;x<=2;x++)
{
for (y=0;y<=2;y++)
{
printf("Dame el elemento %i,%i de la matrix 1\n", x,y);
scanf("%i",& matrix1 [x][y]);
}
}
for (x=0;x<=2;x++)
{
for (y=0;y<=2;y++)
{
printf("Dame el elemento %i,%i de la matrix 2\n\n", x,y);
scanf("%i",& matrix2 [x][y]);
}
}
for (x=0;x<=2;x++)
{
for (y=0;y<=2;y++)
matrix3[x][y]=matrix1[x][y]+matrix2[x][y];
}
for (x=0;x<=2;x++)
{
for (y=0;y<=2;y++)
printf("%i|", matrix3[x][y]);
}
getch ();
return 0;
}
#include <stdio.h>
#include <conio.h>
main()
{
int matrix1[3][3],matrix2[3][3],matrix3[3][3],x,y;
for (x=0;x<=2;x++)
{
for (y=0;y<=2;y++)
{
printf("Dame el elemento %i,%i de la matrix 1\n", x,y);
scanf("%i",& matrix1 [x][y]);
}
}
for (x=0;x<=2;x++)
{
for (y=0;y<=2;y++)
{
printf("Dame el elemento %i,%i de la matrix 2\n\n", x,y);
scanf("%i",& matrix2 [x][y]);
}
}
for (x=0;x<=2;x++)
{
for (y=0;y<=2;y++)
matrix3[x][y]=matrix1[x][y]+matrix2[x][y];
}
for (x=0;x<=2;x++)
{
for (y=0;y<=2;y++)
printf("%i|", matrix3[x][y]);
}
getch ();
return 0;
}
Programa en Clase 19 agosto
#include <stdio.h>
#include <windows.h>
#include <conio.h>
main()
{
int matriz1[3][3], matriz2[3][3], x, y;
for( x = 0; x <= 2; x++)
for( y = 0; y <= 2; y++)
{printf("\n\nDame el elemento %d %d de la matriz 1:", x, y);
scanf("%d", &matriz1[x][y]);}
system("cls");
for( x = 0; x <= 2; x++)
for( y = 0; y <= 2; y++)
{printf("\n\nDame el elemento %d %d de la matriz 2:", x, y);
scanf("%d", &matriz2[x][y]);}
system("cls");
printf("Resultado");
for( x = 0; x <= 2; x++){
printf("\n");
for( y = 0; y <= 2; y++)
printf("%d ", matriz1[x][y]+matriz2[x][y]);
}
printf("\n");
getch ();
}
#include <windows.h>
#include <conio.h>
main()
{
int matriz1[3][3], matriz2[3][3], x, y;
for( x = 0; x <= 2; x++)
for( y = 0; y <= 2; y++)
{printf("\n\nDame el elemento %d %d de la matriz 1:", x, y);
scanf("%d", &matriz1[x][y]);}
system("cls");
for( x = 0; x <= 2; x++)
for( y = 0; y <= 2; y++)
{printf("\n\nDame el elemento %d %d de la matriz 2:", x, y);
scanf("%d", &matriz2[x][y]);}
system("cls");
printf("Resultado");
for( x = 0; x <= 2; x++){
printf("\n");
for( y = 0; y <= 2; y++)
printf("%d ", matriz1[x][y]+matriz2[x][y]);
}
printf("\n");
getch ();
}
Arreglos bidimencionales
Cuando se declara un arreglo de una sola dimencion (int num[4])se esta imaginando en memoria 4 lugares donde se pueden guardar enteros, pero si yo requiero tener mas elementos, digamos como una matriz, entonces se tiene que ampliar ese rango, cuando se declara un arreglo de una dimencion, se tiene un grupo de cuatro elemntos, pero en uno bidimencional se tienen 4 grupos de 4 elementos(int num [3][4]), elprimero seria el de las filas, y el segundo el de las columnas; las columnas van de "0 a 3" y las filas van de "0 a 2", para interpretarlo o leerlo seria primero la Fila y luego la Columna.
Ejemplo x y
1 3 2 int matriz1[3][3], matriz2[3][3], matriz3[3][3], x, y;
1 0 0 for( x = 0; x <= 2; x++)
1 2 2 for( y = 0; y <= 2; y++)
{printf("\n\nDame el elemento %d %d de la matriz 1", x, y);
scanf("%d", &matriz1[x][y]);}
for( x = 0; x <= 2; x++)
for( y = 0; y <= 2; y++)
{printf("\n\nDame el elemento %d %d de la matriz 2:", x, y);
scanf("%d", &matriz2[x][y]);}
//matriz3[x][y]=matriz1[x][y]+matriz2[x][y];
printf("Resultado");
for( x = 0; x <= 2; x++){
printf("\n");
for( y = 0; y <= 2; y++)
printf("%d ", matriz1[x][y]+matriz2[x][y]);
}
Ejemplo x y
1 3 2 int matriz1[3][3], matriz2[3][3], matriz3[3][3], x, y;
1 0 0 for( x = 0; x <= 2; x++)
1 2 2 for( y = 0; y <= 2; y++)
{printf("\n\nDame el elemento %d %d de la matriz 1", x, y);
scanf("%d", &matriz1[x][y]);}
for( x = 0; x <= 2; x++)
for( y = 0; y <= 2; y++)
{printf("\n\nDame el elemento %d %d de la matriz 2:", x, y);
scanf("%d", &matriz2[x][y]);}
//matriz3[x][y]=matriz1[x][y]+matriz2[x][y];
printf("Resultado");
for( x = 0; x <= 2; x++){
printf("\n");
for( y = 0; y <= 2; y++)
printf("%d ", matriz1[x][y]+matriz2[x][y]);
}
Apunte de clase 19 de agosto 2013
int num[10], x;
for (x = 0; x <= 9; x++) for(x = 9; x >= 0; x--)
numx[x]= 10-x num[x]=10-x
Programa metereologico anterior, dado por el profesor
#include <stdio.h>
#include <conio.h>
main();
{int Horas[24], x;
printf("Este programa almacena las temperaturas de las 24 horas de un dia \n\n");
for(x = 0; x <= 23; x++)
{printf("\n Dame la temperatura de la Hora %i:", x);
scanf("%i", &horas[x]);
}
for (x=0;x<=23;x++)
printf("\n la temperatura de la hora es %i en %i", x, horas[x]);
getch ();
}
for (x = 0; x <= 9; x++) for(x = 9; x >= 0; x--)
numx[x]= 10-x num[x]=10-x
Programa metereologico anterior, dado por el profesor
#include <stdio.h>
#include <conio.h>
main();
{int Horas[24], x;
printf("Este programa almacena las temperaturas de las 24 horas de un dia \n\n");
for(x = 0; x <= 23; x++)
{printf("\n Dame la temperatura de la Hora %i:", x);
scanf("%i", &horas[x]);
}
for (x=0;x<=23;x++)
printf("\n la temperatura de la hora es %i en %i", x, horas[x]);
getch ();
}
miércoles, 14 de agosto de 2013
Programa 2 en clase 14 de Agosto 2013
#include <stdio.h>
#include <conio.h>
main()
{
int num[24], i;
for( i = 0; i <= 23; i++ )
{printf("\n Dame la temperatura de la Hora %i:", i+1);
scanf("%i",&num[i]);
}
printf("\n\n Las temperaturas del dia de hoy son:\n\n");
for ( i = 0; i <= 23; i++)
printf("\n En la hora: %i | y los grados fueron %i\n", i, num[i]);
printf("\n\n Enter para fin...");
getch ();
}
#include <conio.h>
main()
{
int num[24], i;
for( i = 0; i <= 23; i++ )
{printf("\n Dame la temperatura de la Hora %i:", i+1);
scanf("%i",&num[i]);
}
printf("\n\n Las temperaturas del dia de hoy son:\n\n");
for ( i = 0; i <= 23; i++)
printf("\n En la hora: %i | y los grados fueron %i\n", i, num[i]);
printf("\n\n Enter para fin...");
getch ();
}
Programa en clase 14 Agosto 2013
#include <stdio.h>
#include <conio.h>
main()
{
int num[10], i;
for( i = 0; i <= 9; i++ )
{printf("\n Leeme un numero entero para quedartelo en el arreglo como elemento %i: \n", i+1);
scanf("%i",&num[i]);
}
printf("\n\n El arreglo tiene los siguientes valores:\n\n");
for ( i = 0; i <= 9; i++)
printf("%i|", num[i]);
printf("\n\n Enter para fin...");
getch ();
}
#include <conio.h>
main()
{
int num[10], i;
for( i = 0; i <= 9; i++ )
{printf("\n Leeme un numero entero para quedartelo en el arreglo como elemento %i: \n", i+1);
scanf("%i",&num[i]);
}
printf("\n\n El arreglo tiene los siguientes valores:\n\n");
for ( i = 0; i <= 9; i++)
printf("%i|", num[i]);
printf("\n\n Enter para fin...");
getch ();
}
Arreglos
Es una estructura estatica, por que del tamaño que se defina, el tamaño ya no puede crecer.
El tipo del arreglo es el tipo de elemento de ese arreglo
int num[10];
Para tener acceso a un arreglo, cada uno de sus elementos se identifican con un indice, ese indice es la posicion que ocupa en el arreglo -1.
0 1 2 3 4 -->Esto es un arreglo de 5 elementos y va de 0 a 4.
para inicializar el arreglo anterior usamos un "for"
for( i = 0; i <= 9; i++ )
{printf("\n Leeme un numero entero para quedartelo en el arreglo como elemento%i", i+1);
scanf("%i",&num[i]);
}
El tipo del arreglo es el tipo de elemento de ese arreglo
int num[10];
Para tener acceso a un arreglo, cada uno de sus elementos se identifican con un indice, ese indice es la posicion que ocupa en el arreglo -1.
0 1 2 3 4 -->Esto es un arreglo de 5 elementos y va de 0 a 4.
para inicializar el arreglo anterior usamos un "for"
for( i = 0; i <= 9; i++ )
{printf("\n Leeme un numero entero para quedartelo en el arreglo como elemento%i", i+1);
scanf("%i",&num[i]);
}
martes, 13 de agosto de 2013
PROGRAMACIÓN Clase 1
OBJETIVO
GENERAL DEL CURSO:
AL FINALIZAR EL CURSO, EL ALUMNO SERÁ
CAPAZ DE ENTENDER LA ABSTRACCIÓN, E IMPLANTAR EN UN LENGUAJE DE PROGRAMACIÓN
LAS ESTRUCTURAS DE DATOS FUNDAMENTALES Y AVANZADAS Y REALIZAR ORDENAMIENTOS Y
BÚSQUEDAS
I.
FUNDAMENTOS DE LAS ESTRUCTURAS DE DATOS
LAS
ESTRUCTURAS DE DATOS SON LA BASE DEL MANEJO DE INFORMACIÓN EN LA PROGRAMACIÓN
CONOCER
LAS OPERACIONES Y SU MANEJO EN MEMORIA, NOS PERMITE CONSTRUIR PROGRAMAS MÁS
EFICACES Y DESARROLLAR APLICACIONES MÁS SEGURAS Y ROBUSTAS
UNA
ESTRUCTURA ES
UN CONJUNTO DE ELEMENTOS RELACIONADOS MEDIANTE LEYES QUE
DETERMINAN SU INTERACCION Y AL MISMO TIEMPO SU RELACION COMO PARTES INTEGRANTES
DE UN TODO
EN
UNA ESTRUCTURA IDEAL, LA ÚNICA RELACION QUE DEBE EXISTIR ENTRE DOS ELEMENTOS
CUALESQUIERA, DEBE SER SOLO A TRAVES DE LA ESTRUCTURA
LAS
ESTRUCTURAS DE DATOS SON FUNDAMENTALES PARA EL DESARROLLO DE SISTEMAS COMPLEJOS
Y PARA EL MANEJO DE INFORMACION
DE
LAS DIFERENTES MANERAS COMO SE RELACIONAN LOS DATOS SE PRODUCEN ESTRUCTURAS DE
MAYOR COMPLEJIDAD
UNA
ESTRUCTURA DE DATOS ES CUALQUIER COLECCIÓN O GRUPO DE DATOS ORGANIZADOS DE TAL
MANERA QUE TENGAN ASOCIADOS UN CONJUNTO DE OPERACIONES QUE PERMITAN
MANIPULARLOS
TIPOS DE ESTRUCTURAS DE DATOS:
•ESTATICAS
•DINAMICAS
ESTATICAS
SU
TAMAÑO SE DEFINE ANTES DE QUE EL PROGRAMA SE EJECUTE Y NO PUEDE MODIFICARSE
(ARREGLOS, REGISTROS Y ARCHIVOS)
DINAMICAS
SIN
LIMITACIÓN EN EL TAMAÑO DE MEMORIA OCUPADO.
SE
TRABAJAN CON APUNTADORES.
(LISTAS,
PILAS, COLAS, ARBOLES BINARIOS Y GRAFOS)
UNA
ESTRUCTURA DINAMICA DE DATOS ES UNA COLECCIÓN DE ELEMENTOS LLAMADOS NODOS, QUE
SON NORMALMENTE REGISTROS
LOS
TIPOS DE DATOS QUE OFRECE CUALQUIER COMPILADOR SE LLAMAN
ESTÁNDAR
O PRIMITIVOS
LOS
TIPOS DE DATOS MANEJADOS POR LA COMPUTADORA BÁSICAMENTE SON DOS
NUMÉRICOS
Y
ALFANUMÉRICOS
NUMÉRICOS
ESTÁN
REPRESENTADOS POR LOS NÚMEROS NATURALES (ENTEROS) Y REALES (FRACCIONARIOS)
ALFANUMÉRICOS
ESTÁN
REPRESENTADOS POR LETRAS Y CARACTERES ESPECIALES
LAS FORMAS DE ORGANIZAR DATOS ESTÁN
DETERMINADAS POR LOS TIPOS DE DATOS DEFINIDOS EN EL LENGUAJE.
UN TIPO DE DATO DETERMINA EL RANGO
DE VALORES QUE PUEDE ALMACENAR, LAS OPERACIONES A QUE PUEDE SER SOMETIDO Y EL
FORMATO DE ALMACENAMIENTO EN MEMORIA.
TIPOS DE DATOS ESTÁNDAR
•ENTERO
•REAL
O DE PUNTO FLOTANTE
•CARÁCTER
•LÓGICOS
O BOOLEANOS
miércoles, 7 de agosto de 2013
Equipo Sweet Dreams
Miembro Correo
Conde Lara Victor Isaac CondeLVI@comunidad.unam.mx
Ramos Tagle Jesus (Harvey Dent) novareu1@hotmail.com
Conde Lara Victor Isaac CondeLVI@comunidad.unam.mx
Ramos Tagle Jesus (Harvey Dent) novareu1@hotmail.com
Suscribirse a:
Entradas (Atom)

