commit d61829a1a79cfc169e8903a7b6377e8a6b54c4e8 Author: juanlf Date: Mon Jun 16 22:54:10 2025 +0200 Backup proyecto Joyfe - Borland diff --git a/CPP/ACTU.CPP b/CPP/ACTU.CPP new file mode 100644 index 0000000..f09da68 --- /dev/null +++ b/CPP/ACTU.CPP @@ -0,0 +1,161 @@ +#include +#include +#include +#include + +FILE *maes, *mov, *maestmp, *historico; +struct clientes{ + char nombre[11], apellidos[21], direccion[21], telefono[11]; + int codigo; +}; +struct maestro { + int codigo; + char nombre[11], apellidos[21]; + char direccion[21], telefono[11]; +}regmaes; +struct movi { + char tipo; + int codigo; + char nombre[10], apellidos[20]; + char direccion[20], telefono[10]; +}regmov; + +void limpiar1(), limpiar2(); + +void main(void){ + struct clientes cli; + mov=fopen("k:\\files\\clientes.mov","r+b"); + if ((maes=fopen("k:\\files\\clientes.dat","r+b"))==NULL){ + //fclose(maes); + maes=fopen("k:\\files\\clientes.dat","w+b"); + while (!feof(mov)){ + limpiar1();limpiar2(); + fread(®mov,sizeof(regmov),1,mov); + if (regmov.tipo=='A') { + strcpy (regmaes.apellidos,regmov.apellidos); + strcpy (regmaes.nombre,regmov.nombre); + regmaes.codigo=regmov.codigo; + strcpy (regmaes.direccion,regmov.direccion); + strcpy (regmaes.telefono,regmov.telefono); + clrscr(); + printf ("%d \n%s \n%s \n%s \n%s", regmaes.codigo, regmaes.nombre,regmaes.apellidos, regmaes.direccion, regmaes.telefono); + getch(); + fwrite (®maes,sizeof(struct maestro),1,maes); + } + } + } + else{ + fclose(maes); + system("rename k:\\files\\clientes.dat clientes.tmp"); + maes=fopen("k:\\files\\clientes.dat","w+b"); + maestmp=fopen("k:\\files\\clientes.tmp","rb"); + historico=fopen("k:\\files\\clientes.log","a+b"); + limpiar1();limpiar2(); + fread(®mov,sizeof(regmov),1,mov); + fread(®maes,sizeof(regmaes),1,maestmp); + while (!feof(mov) && !feof(maestmp)){ + if (regmaes.codigo==regmov.codigo){ + if(regmov.tipo=='A'){ + printf("Error cliente duplicado.");getch(); + fwrite(®maes,sizeof(regmaes),1,maes); + limpiar1();limpiar2(); + fread(®mov,sizeof(regmov),1,mov); + fread(®maes,sizeof(regmaes),1,maestmp); + } + else{ + if (regmov.tipo=='B'){ + printf("Dando de baja..."); + fwrite(®maes,sizeof(regmaes),1,historico); + limpiar1();limpiar2(); + fread(®mov,sizeof(regmov),1,mov); + fread(®maes,sizeof(regmaes),1,maestmp); + } + else{ + fwrite(&(regmov.codigo),2,1,maes); + fwrite(&(regmov.nombre),11,1,maes); + fwrite(&(regmov.apellidos),21,1,maes); + fwrite(&(regmov.direccion),21,1,maes); + fwrite(&(regmov.telefono),11,1,maes); + limpiar1();limpiar2(); + fread(®mov,sizeof(regmov),1,mov); + fread(®maes,sizeof(regmaes),1,maestmp); + } + } + } + else{ + if(regmov.codigo>regmaes.codigo){ + fwrite(®maes,sizeof(regmaes),1,maes); + limpiar2(); + fread(®maes,sizeof(regmaes),1,maestmp); + } + else{ + if (regmov.tipo=='A'){ + fwrite(&(regmov.codigo),2,1,maes); + fwrite(&(regmov.nombre),10,1,maes); + fwrite(&(regmov.apellidos),20,1,maes); + fwrite(&(regmov.direccion),20,1,maes); + fwrite(&(regmov.telefono),10,1,maes); + } + else{ + printf("Error: El cliente no existe.");getch(); + } + limpiar1(); + fread(®mov,sizeof(regmov),1,mov); + } + } + } // fin del while + + + if (!feof(mov)){ + while(!feof(mov)){ + if(regmov.tipo=='A'){ + strcpy (regmaes.apellidos,regmov.apellidos); + strcpy (regmaes.nombre,regmov.nombre); + regmaes.codigo=regmov.codigo; + strcpy (regmaes.direccion,regmov.direccion); + strcpy (regmaes.telefono,regmov.telefono); + clrscr(); + printf ("%d \n%s \n%s \n%s \n%s", regmaes.codigo, regmaes.nombre,regmaes.apellidos, regmaes.direccion, regmaes.telefono); + getch(); + fwrite (®maes,sizeof(struct maestro),1,maes); + } + else{ + printf("Error: El cliente no existe.");getch(); + } + limpiar1(); + fread(®mov,sizeof(regmov),1,mov); + } + } + else{ + if(!feof(maestmp)){ + while(!feof(maestmp)){ + fwrite(®maes,sizeof(regmaes),1,maes); + limpiar2(); + fread(®maes,sizeof(regmaes),1,maestmp); + } + } + } + fcloseall(); + } + unlink("k:\\files\\clientes.mov"); + unlink("k:\\files\\clientes.tmp"); +} + +void limpiar1(){ + regmov.tipo=NULL;regmov.codigo=0; + for (int n=0;n<21;n++){ + regmov.apellidos[n]=NULL;regmov.direccion[n]=NULL; + } + for(n=0;n<11;n++){ + regmov.nombre[n]=NULL;regmov.telefono[n]=NULL; + } +} +void limpiar2(){ + for (int n=0;n<21;n++){ + regmaes.apellidos[n]=NULL;regmaes.direccion[n]=NULL; + } + for (n=0;n<11;n++){ + regmaes.nombre[n]=NULL;regmaes.telefono[n]=NULL; + } + regmaes.codigo=0; +} \ No newline at end of file diff --git a/CPP/ARBOL.CPP b/CPP/ARBOL.CPP new file mode 100644 index 0000000..976b24b --- /dev/null +++ b/CPP/ARBOL.CPP @@ -0,0 +1,238 @@ +#include +#include +#include +#include +#include +#include + +struct nodo { + int dato; + struct nodo *padre; + struct nodo *hi; + struct nodo *hd; +}; + +int ARBOL_VACIO (struct nodo *); +void INI_ARBOL (struct nodo **); +void INS_ARBOL (struct nodo **, int); +int PROFUNDIDAD (struct nodo *); +void ELIMINAR_NODO (struct nodo **, struct nodo *); +void LISTAR_IRD(struct nodo *); +struct nodo* BUSCAR_NODO(struct nodo*,int); + +void main (void) { + + int d; + + struct nodo *arbol; + + INI_ARBOL(&arbol); + + + clrscr(); + + while (d!=0){ + printf ("\nNumero: "); + cin >> d; + if (d!=0) + INS_ARBOL(&arbol, d); + } + printf("Presione ENTER para continuar, ESC finaliza.\n"); + printf ("\nListado del  rbol:"); + printf ("\n------------------\n"); + LISTAR_IRD(arbol); + printf ("\n------------------\n"); + cout << "\nLa profundidad del  rbol es " << PROFUNDIDAD(arbol); + printf("\nLado Izquierdo-> %d", PROFUNDIDAD(arbol->hi)); + printf("\tLado Derecho-> %d", PROFUNDIDAD(arbol->hd)); + printf("\n Raiz: %d",arbol->dato);getch(); + getch(); + int victima; + while (!ARBOL_VACIO(arbol)) { + printf("\nIntroduce un nodo a eliminar: "); + + cin >> victima; + ELIMINAR_NODO(&arbol,BUSCAR_NODO(arbol,victima)); + printf ("\nListado del  rbol:"); + printf ("\n------------------\n"); + LISTAR_IRD(arbol); + printf ("\n------------------\n"); + cout << "\nLa profundidad del  rbol es " << PROFUNDIDAD(arbol); + printf("\nLado Izquierdo-> %d", PROFUNDIDAD(arbol->hi)); + printf("\tLado Derecho-> %d", PROFUNDIDAD(arbol->hd)); + + if (arbol!=NULL) + printf("\n Raiz: %d",(arbol->dato));getch(); + + + + getch(); + } + + free (arbol); +} + + + + +int ARBOL_VACIO(struct nodo *p) { + return (p == NULL); + } + +void INI_ARBOL(struct nodo **p) { *p = NULL; } + +void INS_ARBOL(struct nodo **p, int n) { + struct nodo *aux; + struct nodo **q; + int sw; + + if ((aux = (struct nodo*) malloc (sizeof (struct nodo)))== NULL) + exit(1); + aux->dato = n; + + if (ARBOL_VACIO(*p)) { + aux->hi = NULL; + aux->hd = NULL; + aux->padre = aux; + *p = aux; + } + else { + sw = 1; + q = p; + while (sw) { + sw = 0; + if ((*q)->dato <= n && (*q)->hd != NULL) { + q = &(*q)->hd; + sw = 1; + } + if ((*q)->dato >= n && (*q)->hi != NULL) { + q = &(*q)->hi; + sw = 1; + } + } + aux->hi = aux->hd = NULL; + aux->padre = (*q); + ((*q)->dato < n) ? (*q)->hd = aux : (*q)->hi = aux; + } +} + + +int PROFUNDIDAD(struct nodo *p) { + int nivelhi=0; + int nivelhd=0; + if (p != NULL) { + nivelhi++; + nivelhi+=PROFUNDIDAD(p -> hi); + nivelhd++; + nivelhd+=PROFUNDIDAD(p -> hd); + } + return (nivelhd > nivelhi) ? nivelhd : nivelhi; +} + + +void ELIMINAR_NODO (struct nodo **p, struct nodo *q) { + if (q==NULL) + printf("Error. Se ha intentado eliminar un nodo NO EXISTENTE."); + else { + if (q->hd == NULL && q->hi == NULL && q->padre != q) { // ES HOJA + if ((q->padre)->hd == q) + (q->padre)->hd = NULL; // ES UN HD + else + (q->padre)->hi = NULL; // ES UN HI + } // fin del if si es hoja + else { + if ((q->padre) == q && q->hd == NULL && q->hi == NULL)// RAIZ SIN HIJOS + *p = NULL; + else { + if (q->hd != NULL && q->hi == NULL) {// NO TIENE HI + if (q->padre==q) + *p=q->hd; + else + if ((q->padre)->hd == q) // ES UN HD + (q->padre)->hd = q->hd; + else + (q->padre)->hi = q->hd; // ES UN HI + } // fin del if no tiene HI + else { + if (q->hd == NULL && q->hi != NULL) {// NO TIENE HD + if (q->padre==q) + *p=q->hi; + else + if ((q->padre)->hd == q) + (q->padre)->hd = q->hi; + else + (q->padre)->hi = q->hi; + } // fin del if no tiene hd + else { + if (q->hd != NULL && q->hi != NULL){ //TIENE 2 HIJOS + struct nodo *aux = NULL; + if (PROFUNDIDAD(q->hi) > (PROFUNDIDAD (q->hd))) { + aux=q->hi; + while (aux->hd != NULL) {aux = aux->hd;} + } + else { + aux=q->hd; + while (aux->hi != NULL) {aux = aux->hi;} + } + struct nodo *nodotmp = NULL; + if ((nodotmp = (struct nodo*) malloc (sizeof (struct nodo)))==NULL){ + printf ("\nError Memory Allocation !!"); + printf ("\nNo hay memoria suficiente, abortando ..."); + exit(1); + } + + nodotmp->dato = aux->dato; + + if (q->hd == aux) + nodotmp->hd = aux->hd; + else + nodotmp->hd = q->hd; + + if (q->hi == aux) + nodotmp->hi = aux->hi; + else + nodotmp->hi = q->hi; + + if ((q->padre)==q){ // ES RAIZ + *p = nodotmp; + nodotmp->padre=nodotmp; + } + else + if ((q->padre)->hd == q) {// ES UN HD + (q->padre)->hd = nodotmp; + nodotmp->padre=q->padre; + } + else { + (q->padre)->hi = nodotmp; // ES UN HI + nodotmp->padre=q->padre; + } + + ELIMINAR_NODO(p, aux); + + } // fin del if + } // fin del else + } // fin del else + } // fin del else + } // fin del else + } // fin del else + free (q); +} // fin de la funcion eliminar_nodo + + +void LISTAR_IRD(struct nodo *p){ + if (p!=NULL){ + LISTAR_IRD(p->hi); + printf("%d ",p->dato); + LISTAR_IRD(p->hd); + } +} + +struct nodo* BUSCAR_NODO(struct nodo *p,int n){ + if (p==NULL || n==p->dato) + return p; + else + if (ndato) + return (BUSCAR_NODO(p->hi,n)); + else + return (BUSCAR_NODO(p->hd,n)); +} \ No newline at end of file diff --git a/CPP/ARBOL.EXE b/CPP/ARBOL.EXE new file mode 100644 index 0000000..0675467 Binary files /dev/null and b/CPP/ARBOL.EXE differ diff --git a/CPP/ARBOL.OBJ b/CPP/ARBOL.OBJ new file mode 100644 index 0000000..6be7830 Binary files /dev/null and b/CPP/ARBOL.OBJ differ diff --git a/CPP/ARBOLBI.CPP b/CPP/ARBOLBI.CPP new file mode 100644 index 0000000..ef4ae41 --- /dev/null +++ b/CPP/ARBOLBI.CPP @@ -0,0 +1,313 @@ +#include +#include +#include +#include +#include + +struct nodo{ + int dato; + struct nodo *hi; + struct nodo *hd; + struct nodo *padre; +}; + +void insertar (struct nodo **,int); +int esvacio(struct nodo *); +void listar_ird(struct nodo *); +struct nodo* buscar_nodo(struct nodo*,int); +void eliminar_nodo(struct nodo**,struct nodo*); +void eliminar(struct nodo*,struct nodo*); + +void main(void){ + struct nodo *arbol=NULL,*aux=NULL;int n=0;char tecla=NULL; + do{ + clrscr(); + printf ("Inserta nuevo nodo:"); + cin >> n; + aux=buscar_nodo(arbol,n); + if (aux==NULL){ + insertar(&arbol,n); + printf ("\nPara finalizar de introducir nodos pulse ESC."); + tecla=getch(); + } + else{ + nosound();sound(500);delay(500);nosound(); + } + }while (tecla!=27); + clrscr(); + listar_ird(arbol);getch(); + while (n!=0){ + printf ("\nRaiz %d",arbol->dato); + printf("\nIndica el nodo a eliminar: \n"); + cin >> n; + aux=buscar_nodo(arbol,n); + eliminar(arbol,aux); + listar_ird(arbol);getch(); + } + +} + + +int esvacio(struct nodo *p){ + return(p==NULL); +} + +void insertar (struct nodo **p,int n){ + struct nodo *aux=NULL; + if ((aux=(struct nodo *)malloc(sizeof(struct nodo)))==NULL){ + clrscr(); + printf ("No hay memoria suficiente."); + getch(); + exit(1); + } + else{ + if (esvacio(*p)){ + aux->dato=n;aux->hd=NULL;aux->hi=NULL;aux->padre=aux; + (*p)=aux; + } + else{ + struct nodo **q=NULL; + q=p;int sw=1; + while (sw==1){ + sw=0; + if ((*q)->datohd!=NULL){ + q=&((*q)->hd);sw=1; + } + if ((*q)->dato>n && (*q)->hi!=NULL){ + q=&((*q)->hi);sw=1; + } + } + aux->dato=n;aux->hi=NULL;aux->hd=NULL;aux->padre=(*q); + if ((*q)->datohd=aux; + else + (*q)->hi=aux; + } + } +} + +void listar_ird(struct nodo *p) { //int x,int y){ + if (p!=NULL){ + //gotoxy(x,y); + printf("%d ",p->dato); + listar_ird(p->hi); + listar_ird(p->hd); + } +} + +struct nodo* buscar_nodo(struct nodo *p,int n){ + if (p==NULL || n==p->dato) + return p; + else + if (ndato) + return (buscar_nodo(p->hi,n)); + else + return (buscar_nodo(p->hd,n)); +} + +void eliminar(struct nodo *tree,struct nodo *aux){ + if (aux==NULL){ + printf ("El nodo no existe");getch(); + } + else{ + if (aux->hi==NULL && aux->hd==NULL && aux->padre!=aux){ + if((aux->padre)->hi==aux) + (aux->padre)->hi=NULL; + else + if((aux->padre)->hd==aux) + (aux->padre)->hd=NULL; + } + else + if(aux->padre==aux && aux->hi==NULL && aux->hd==NULL) + tree=NULL; + else + eliminar_nodo(&tree,aux); + free(aux); + listar_ird(tree);getch(); + } +} + + +void eliminar_nodo(struct nodo**p,struct nodo*q){ + if (q->padre!=q){ + if (q->hi!=NULL){ + if((q->hi)->hd==NULL){ + if ((q->padre)->hd==q) + (q->padre)->hd=q->hi; + else + if((q->padre)->hi==q) + (q->padre)->hi=q->hi; + (q->hi)->padre=q->padre; + (q->hi)->hd=q->hd; + if (q->hd!=NULL) + ((q->hi)->hd)->padre=q->hi; + } + else{ + struct nodo *aux=NULL; + if ((aux=(struct nodo *)malloc(sizeof(struct nodo)))==NULL){ + clrscr(); + printf ("No hay memoria suficiente."); + getch(); + exit(1); + } + else{ + aux=(q->hi)->hd; + while(aux->hd!=NULL) + aux=aux->hd; + if (aux->hi!=NULL) + eliminar_nodo(p,aux); + else + if ((aux->padre)->hd==aux) + (aux->padre)->hd=NULL; + else + if((aux->padre)->hi==aux) + (aux->padre)->hi=NULL; +// else +// if ((q->hd)->hd==aux) +// (q->hd)->hd=NULL; +// else +// if((q->hd)->hi==aux) +// (q->hd)->hi=NULL; + if ((q->padre)->hd==q) + (q->padre)->hd=aux; + else + if ((q->padre)->hi==q) + (q->padre)->hi=aux; + aux->padre=q->padre; + aux->hi=q->hi; + if (aux->hi!=NULL) + (aux->hi)->padre=aux; + aux->hd=q->hd; + if (aux->hd!=NULL) + (aux->hd)->padre=aux; + } + } + } + else{ + if (q->hd!=NULL){ + if((q->hd)->hi==NULL){ + if ((q->padre)->hd==q) + (q->padre)->hd=q->hd; + else + if((q->padre)->hi==q) + (q->padre)->hi=q->hd; + (q->hd)->padre=q->padre; + (q->hd)->hi=q->hi; + if (q->hi!=NULL) + ((q->hd)->hi)->padre=q->hd; + } + else{ + struct nodo *aux=NULL; + if ((aux=(struct nodo *)malloc(sizeof(struct nodo)))==NULL){ + clrscr(); + printf ("No hay memoria suficiente."); + getch(); + exit(1); + } + else{ + aux=(q->hd)->hi; + while(aux->hi!=NULL) + aux=aux->hi; + if (aux->hd!=NULL) + eliminar_nodo(p,aux); + else + if ((aux->padre)->hd==aux) + (aux->padre)->hd=NULL; + else + if((aux->padre)->hi==aux) + (aux->padre)->hi=NULL; +// else +// if ((q->hd)->hd==aux) +// (q->hd)->hd=NULL; +// else +// if((q->hd)->hi==aux) +// (q->hd)->hi=NULL; + if ((q->padre)->hd==q) + (q->padre)->hd=aux; + else + if ((q->padre)->hi==q) + (q->padre)->hi=aux; + aux->padre=q->padre; + aux->hi=q->hi; + if (aux->hi!=NULL) + (aux->hi)->padre=aux; + aux->hd=q->hd; + if (aux->hd!=NULL) + (aux->hd)->padre=aux; + } + } + } + } + } + else{ + if (q->hi!=NULL){ + if((q->hi)->hd==NULL){ + (q->hi)->hd=(*p)->hd; + (*p)=q->hi; + (q->hi)->padre=q->hi; + + } + else{ + struct nodo *aux=NULL; + if ((aux=(struct nodo *)malloc(sizeof(struct nodo)))==NULL){ + clrscr(); + printf ("No hay memoria suficiente."); + getch(); + exit(1); + } + else{ + aux=(q->hi)->hd; + while(aux->hd!=NULL) + aux=aux->hd; + if (aux->hi!=NULL) + eliminar_nodo(p,aux); + (*p)=aux; + aux->padre=aux; + aux->hi=q->hi; + if (aux->hi!=NULL) + (aux->hi)->padre=aux; + aux->hd=q->hd; + if (aux->hd!=NULL) + (aux->hd)->padre=aux; + } + } + } + else{ + if (q->hd!=NULL){ + if((q->hd)->hi==NULL){ + (*p)=q->hd; + (q->hd)->padre=q->hd; + } + else{ + struct nodo *aux=NULL; + if ((aux=(struct nodo *)malloc(sizeof(struct nodo)))==NULL){ + clrscr(); + printf ("No hay memoria suficiente."); + getch(); + exit(1); + } + else{ + aux=(q->hd)->hi; + while(aux->hi!=NULL) + aux=aux->hi; + if (aux->hd!=NULL) + eliminar_nodo(p,aux); + (*p)=aux; + if ((aux->padre)->hd==aux) + (aux->padre)->hd=NULL; + else + if((aux->padre)->hi==aux) + (aux->padre)->hi=NULL; + aux->padre=aux; + aux->hi=q->hi; + if (aux->hi!=NULL) + (aux->hi)->padre=aux; + aux->hd=q->hd; + if (aux->hd!=NULL) + (aux->hd)->padre=aux; + } + } + } + } + } +} diff --git a/CPP/ARCON.CPP b/CPP/ARCON.CPP new file mode 100644 index 0000000..5fe8b3f --- /dev/null +++ b/CPP/ARCON.CPP @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include + +struct nodo { + int dato; + struct nodo *padre; + struct nodo *hi; + struct nodo *hd; +}; + +int ARBOL_VACIO (struct nodo *); +void INI_ARBOL (struct nodo **); +void INS_ARBOL (struct nodo **, int); +int LISTAR_IRD (struct nodo *); + +void main (void) { + + int d; + + struct nodo *arbol; + + INI_ARBOL(&arbol); + for (int i=0; i<37; i++) { + printf("\n Introduce n£mero: "); + fflush (stdin); + scanf ("%d", &d); + INS_ARBOL(&arbol, d); + } + printf("Numero de niveles -> %d",LISTAR_IRD(arbol)); + getch(); + free (arbol); +} + +int ARBOL_VACIO(struct nodo *p) { + if (p == NULL) + return (1); + else + return (0); + } + +void INI_ARBOL(struct nodo **p) { *p = NULL; } + +void INS_ARBOL(struct nodo **p, int n) { + struct nodo *aux; + struct nodo **q; + int sw; + + if ((aux = (struct nodo*) malloc (sizeof (struct nodo)))== NULL) + exit(1); + aux -> dato = n; + + if (ARBOL_VACIO(*p)) { + aux -> hi = NULL; + aux -> hd = NULL; + aux -> padre = aux; + *p = aux; + } + else { + + sw = 1; + q = p; + while (sw) { + sw = 0; + if ((*q) -> dato <= n && (*q) -> hd != NULL) { + q = &(*q) -> hd; + sw = 1; + } + if ((*q) -> dato >= n && (*q) -> hi != NULL) { + q = &(*q) -> hi; + sw = 1; + } + } + aux -> hi = aux -> hd = NULL; + aux -> padre = (*q); + ((*q) -> dato < n) ? (*q) -> hd = aux : (*q) -> hi = aux; + + } +} + +int LISTAR_IRD(struct nodo *p) { + static int max=0; + + static int nivel=1; + if (p != NULL) + { + + nivel++;LISTAR_IRD(p -> hi); + if (nivel>max) + max=nivel; + nivel--; + //printf (" %d ", p -> dato); + + nivel++;LISTAR_IRD(p -> hd); + nivel--; + if (nivel>max) + max=nivel; + + } +return (max-1); +} \ No newline at end of file diff --git a/CPP/BASE.C b/CPP/BASE.C new file mode 100644 index 0000000..b1debed --- /dev/null +++ b/CPP/BASE.C @@ -0,0 +1,101 @@ + +#include +#include + +int digitos,baseini,basefinal,num,numfinal,tabla[80],tabla_bien[80]; + +int Pedir_Base(); +int Pedir_Num(int baseini); +int BaseDiez_Base(int num,int basefinal); +int Transform(int num); +void Imprimir_tabla(int digitos); + +void main() { + clrscr(); + baseini=Pedir_Base(); + num=Pedir_Num(baseini); + basefinal=Pedir_Base(); + digitos=BaseDiez_Base(num,basefinal); + Imprimir_tabla(digitos); + + printf("\nPulse una tecla para finalizar ..."); + getch(); + +} + +int Pedir_Base() { + int b; + do { + printf("\nIntroduce la Base: "); + fflush(stdin); + scanf("%d",&b); + } while (b<2 || b>16); + return(b); +} + +int Pedir_Num(int baseini) { + int seguir=1,k=0,nuevo=0,numero;char n=0; + printf("Introduce un n£mero: "); + while (seguir) { + fflush(stdin); cscanf("%1c",&n); + if (n==13) + seguir=0; + else + k=Transform(n); + if (seguir) + if (k=0;i--) { + tabla_bien[pos]=tabla[i]; + printf("\ntablabien[%d]=%d",i,tabla_bien[pos]); + pos++; + } +return(digitos); +} + +int Transform(int num) { + int k=0; + if (num>=48 && num <=57) + k=(num-48); + else + if (num>=65 && num <=70) + k=(num-55); + else + if (num>=97 && num <=102) + k=(num-87); + else + k=99; +return(k); +} + +void Imprimir_tabla(int digitos) { + //printf("\n llegan digitos=%d\n",digitos); + printf("\nEl n£mero pedido es: "); + for (int i=0;i<=digitos;i++) + printf("%x",tabla_bien[i]); + +} diff --git a/CPP/BASE.CPP b/CPP/BASE.CPP new file mode 100644 index 0000000..b1debed --- /dev/null +++ b/CPP/BASE.CPP @@ -0,0 +1,101 @@ + +#include +#include + +int digitos,baseini,basefinal,num,numfinal,tabla[80],tabla_bien[80]; + +int Pedir_Base(); +int Pedir_Num(int baseini); +int BaseDiez_Base(int num,int basefinal); +int Transform(int num); +void Imprimir_tabla(int digitos); + +void main() { + clrscr(); + baseini=Pedir_Base(); + num=Pedir_Num(baseini); + basefinal=Pedir_Base(); + digitos=BaseDiez_Base(num,basefinal); + Imprimir_tabla(digitos); + + printf("\nPulse una tecla para finalizar ..."); + getch(); + +} + +int Pedir_Base() { + int b; + do { + printf("\nIntroduce la Base: "); + fflush(stdin); + scanf("%d",&b); + } while (b<2 || b>16); + return(b); +} + +int Pedir_Num(int baseini) { + int seguir=1,k=0,nuevo=0,numero;char n=0; + printf("Introduce un n£mero: "); + while (seguir) { + fflush(stdin); cscanf("%1c",&n); + if (n==13) + seguir=0; + else + k=Transform(n); + if (seguir) + if (k=0;i--) { + tabla_bien[pos]=tabla[i]; + printf("\ntablabien[%d]=%d",i,tabla_bien[pos]); + pos++; + } +return(digitos); +} + +int Transform(int num) { + int k=0; + if (num>=48 && num <=57) + k=(num-48); + else + if (num>=65 && num <=70) + k=(num-55); + else + if (num>=97 && num <=102) + k=(num-87); + else + k=99; +return(k); +} + +void Imprimir_tabla(int digitos) { + //printf("\n llegan digitos=%d\n",digitos); + printf("\nEl n£mero pedido es: "); + for (int i=0;i<=digitos;i++) + printf("%x",tabla_bien[i]); + +} diff --git a/CPP/BUENO.CPP b/CPP/BUENO.CPP new file mode 100644 index 0000000..840f8a7 --- /dev/null +++ b/CPP/BUENO.CPP @@ -0,0 +1,94 @@ +// Minicalculator© Ver 2.1 +// Copyright 1998 +// +// Descripci¢n del programa: +// Este programa pide dos n£meros, luego muestra un men£ y dependiendo +// de la opci¢n elegida los suma, resta, multiplica o divide imprimiendo +// el resultado de la operaci¢n. +// +// Programadores: +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// Grupo 1§A +// +// Novedades de la Versi¢n 2.1 +// Presenta un mensaje de error si la opci¢n no est  en el men£ +// o si la divisi¢n es por cero. Adem s cuando la divisi¢n no es exacta +// se imprime el resto. Tambi‚n se ha mejorado la interface con el usuario. +// +// Creado: 3-11-1998 +// éltima modificaci¢n: 10-11-1998 + +#include +#include + +int a,b,c; +char pausa; +void main () +{ + clrscr(); + printf ("\n\t\t\t Minicalculator© Ver 2.1"); + printf ("\n\t\t\t ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"); + printf ("\n\n\n\n\t\t Introduce primer n£mero: "); + fflush (stdin); + scanf ("%d",&a); + printf ("\n\n\t\t Introduce segundo n£mero: "); + fflush (stdin); + scanf ("%d",&b); + + clrscr(); + printf ("\n\t\t\t Minicalculator© Ver 2.1"); + printf ("\n\t\t\t ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"); + printf ("\n\n\n\t\t\t Men£ de opciones"); + printf ("\n\n\t\t 1.- Sumar los n£meros introducidos."); + printf ("\n\t\t 2.- Restar los n£meros introducidos."); + printf ("\n\t\t 3.- Multiplicar los n£meros introducidos."); + printf ("\n\t\t 4.- Dividir los n£meros introducidos."); + printf ("\n\n\t\t Opci¢n deseada: "); + fflush(stdin); + scanf ("%d",&c); + + if (c==1) + { + printf ("\n\t\t La suma de los n£meros (%d+%d) es: %d",a,b,a+b); + } + else + { + if (c==2) + { + printf ("\n\t\t La resta de los n£meros (%d-%d) es: %d",a,b,a-b); + } + else + { + if (c==3) + { + printf ("\n\t\t La multiplicaci¢n de los n£meros (%d*%d) es: %d",a,b,a*b); + } + else + { + if (c==4) + { + if (b==0) + { + printf ("\n\t\t ­­ Error !!, no se puede dividir por cero."); + } + else + { + printf ("\n\t\t La divisi¢n de los n£meros (%d/%d) es: %d",a,b,a/b); + if (a%b!=0) + { + printf (" Resto: %d",a%b); + } + } + } + else + { + printf ("\n\n\t\t\t­­ Opci¢n incorrecta !!"); + } + } + } + } + printf ("\n\n\n\n\n\n\n\n\n Pulse ENTER para finalizar..."); + fflush(stdin); + scanf("%c",&pausa); +} \ No newline at end of file diff --git a/CPP/CONIO.H b/CPP/CONIO.H new file mode 100644 index 0000000..5fdbe76 --- /dev/null +++ b/CPP/CONIO.H @@ -0,0 +1,146 @@ +/* conio.h + + Direct MSDOS console input/output. + + Copyright (c) 1987, 1991 by Borland International + All Rights Reserved. +*/ + +#if !defined(__CONIO_H) +#define __CONIO_H + +#if !defined(__DEFS_H) +#include <_defs.h> +#endif + +#define _NOCURSOR 0 +#define _SOLIDCURSOR 1 +#define _NORMALCURSOR 2 + +struct text_info { + unsigned char winleft; + unsigned char wintop; + unsigned char winright; + unsigned char winbottom; + unsigned char attribute; + unsigned char normattr; + unsigned char currmode; + unsigned char screenheight; + unsigned char screenwidth; + unsigned char curx; + unsigned char cury; +}; + +enum text_modes { LASTMODE=-1, BW40=0, C40, BW80, C80, MONO=7, C4350=64 }; + +#if !defined(__COLORS) +#define __COLORS + +enum COLORS { + BLACK, /* dark colors */ + BLUE, + GREEN, + CYAN, + RED, + MAGENTA, + BROWN, + LIGHTGRAY, + DARKGRAY, /* light colors */ + LIGHTBLUE, + LIGHTGREEN, + LIGHTCYAN, + LIGHTRED, + LIGHTMAGENTA, + YELLOW, + WHITE +}; +#endif + +#define BLINK 128 /* blink bit */ + +extern int _Cdecl directvideo; +extern int _Cdecl _wscroll; + +#ifdef __cplusplus +extern "C" { +#endif + +void _Cdecl clreol( void ); +void _Cdecl clrscr( void ); +void _Cdecl gotoxy( int __x, int __y ); +int _Cdecl wherex( void ); +int _Cdecl wherey( void ); +int _Cdecl getch( void ); +int _Cdecl getche( void ); +int _Cdecl kbhit( void ); +int _Cdecl putch( int __c ); + +#ifndef _PORT_DEFS +int _Cdecl inp( unsigned __portid ); +unsigned _Cdecl inpw( unsigned __portid ); +int _Cdecl outp( unsigned __portid, int __value ); +unsigned _Cdecl outpw( unsigned __portid, unsigned __value ); +unsigned char _Cdecl inportb( int __portid ); +void _Cdecl outportb( int __portid, unsigned char __value ); +#endif /* !_PORT_DEFS */ + +int _Cdecl inport( int __portid ); +void _Cdecl outport( int __portid, int __value ); + +void _Cdecl delline( void ); +int _Cdecl gettext( int __left, int __top, + int __right, int __bottom, + void *__destin); +void _Cdecl gettextinfo (struct text_info *__r ); +void _Cdecl highvideo( void ); +void _Cdecl insline( void ); +void _Cdecl lowvideo( void ); +int _Cdecl movetext( int __left, int __top, + int __right, int __bottom, + int __destleft, int __desttop ); +void _Cdecl normvideo( void ); +int _Cdecl puttext( int __left, int __top, + int __right, int __bottom, + void *__source ); +void _Cdecl textattr( int __newattr ); +void _Cdecl textbackground( int __newcolor ); +void _Cdecl textcolor( int __newcolor ); +void _Cdecl textmode( int __newmode ); +void _Cdecl window( int __left, int __top, int __right, int __bottom); + +void _Cdecl _setcursortype( int __cur_t ); +char * _Cdecl cgets( char *__str ); +int _Cdecl cprintf( const char *__format, ... ); +int _Cdecl cputs( const char *__str ); +int _Cdecl cscanf( const char *__format, ... ); +char * _Cdecl getpass( const char *__prompt ); +int _Cdecl ungetch( int __ch ); + +#ifndef _PORT_DEFS +#define _PORT_DEFS + + /* These are in-line functions. These prototypes just clean up + some syntax checks and code generation. + */ +unsigned char _Cdecl __inportb__( int __portid ); +unsigned int _Cdecl __inportw__( int __portid ); +void _Cdecl __outportb__( int __portid, unsigned char __value ); +void _Cdecl __outportw__( int __portid, unsigned int __value ); + +#define inportb __inportb__ +#define inportw __inportw__ +#define outportb __outportb__ +#define outportw __outportw__ + +#define inp( portid ) __inportb__( portid ) +#define outp( portid,v ) (__outportb__( portid,v ), (int)_AL) +#define inpw( portid ) __inportw__( portid ) +#define outpw( portid,v ) (__outportw__( portid,v ), (unsigned)_AX) + +#endif /* _PORT_DEFS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CONIO_H */ diff --git a/CPP/CURSOR.BAK b/CPP/CURSOR.BAK new file mode 100644 index 0000000..d589ddb --- /dev/null +++ b/CPP/CURSOR.BAK @@ -0,0 +1,126 @@ +#include +char i = 0, a = 0; +int col, sw = 0; +int fil; + +void main () { + clrscr (); + fflush (stdin); + gotoxy (10, 10); + printf ("Mueve cursor:"); + while (sw == 0) { + + + //gotoxy(wherex(),wherey()); + + i = getche (); + + + col = wherex (); + + + col--; + + + fil = wherey (); + + + if (i == 0) + + + { + + + //printf("dentro de i=0"); + + a = getch (); + + + + + switch (a) + + + { + + + case 72: + + + { + + + gotoxy (col, fil - 1); + + + // printf("col= %d, fil= %d",col,fil); + + // getch(); + + break; + + + } + + + case 80: + + + gotoxy (col, fil + 1); + + + break; + + + case 77: + + + gotoxy (col + 1, fil); + + + break; + + + case 75: + + + gotoxy (col - 1, fil); + + + break; + + + } + + + // getch(); + + } + + + else + + + sw = 1; + + + } + + + printf ("fin"); + + + getch (); + + + fflush (stdin); + + + clrscr (); + + + + +} + + diff --git a/CPP/CURSOR.C b/CPP/CURSOR.C new file mode 100644 index 0000000..2880bcd --- /dev/null +++ b/CPP/CURSOR.C @@ -0,0 +1,91 @@ +#include +char i = 0, a = 0; +int col, sw = 0; +int fil; + +void main () { + clrscr (); + fflush (stdin); + gotoxy (10, 10); + printf ("Mueve cursor:"); + while (sw == 0) { + /*gotoxy(wherex(),wherey());*/ + i = getche (); + col = wherex (); + col--; + fil = wherey (); + if (i == 0) { + /* //printf("dentro de i=0");*/ + a = getch (); + switch (a) { + case 72: { + gotoxy (col, fil - 1); +/* // printf("col= %d, fil= %d",col,fil);*/ + + /* // getch();*/ + + break; + + + } + + + case 80: + + + gotoxy (col, fil + 1); + + + break; + + + case 77: + + + gotoxy (col + 1, fil); + + + break; + + + case 75: + + + gotoxy (col - 1, fil); + + + break; + + + } + + +} + + + else + + + sw = 1; + + + } + + + printf ("fin"); + + + getch (); + + + fflush (stdin); + + + clrscr (); + + + + +} + + diff --git a/CPP/CURSOR.CPP b/CPP/CURSOR.CPP new file mode 100644 index 0000000..565436b --- /dev/null +++ b/CPP/CURSOR.CPP @@ -0,0 +1,54 @@ +#include +#include +char i=0, a=0; +int col,sw=0; +int fil; +void main() +{ + clrscr(); + fflush(stdin); + gotoxy(10,10); + printf("Mueve cursor:"); + + while(sw==0) + { + //gotoxy(wherex(),wherey()); + i=getche(); + col=wherex(); + col--; + fil=wherey(); + if(i==0) + { + //printf("dentro de i=0"); + a=getch(); + + switch(a) + { + case 72: + { + gotoxy(col,fil-1); + // printf("col= %d, fil= %d",col,fil); + // getch(); + break; + } + case 80: + gotoxy(col,fil+1); + break; + case 77: + gotoxy(col+1,fil); + break; + case 75: + gotoxy(col-1,fil); + break; + } + // getch(); + } + else + sw=1; + } +printf("fin"); +getch(); +fflush(stdin); +clrscr(); + +} \ No newline at end of file diff --git a/CPP/CURSOR.H b/CPP/CURSOR.H new file mode 100644 index 0000000..e69de29 diff --git a/CPP/CURSOR.O b/CPP/CURSOR.O new file mode 100644 index 0000000..bcf0ea4 Binary files /dev/null and b/CPP/CURSOR.O differ diff --git a/CPP/CURSOR~1.ESV b/CPP/CURSOR~1.ESV new file mode 100644 index 0000000..2880bcd --- /dev/null +++ b/CPP/CURSOR~1.ESV @@ -0,0 +1,91 @@ +#include +char i = 0, a = 0; +int col, sw = 0; +int fil; + +void main () { + clrscr (); + fflush (stdin); + gotoxy (10, 10); + printf ("Mueve cursor:"); + while (sw == 0) { + /*gotoxy(wherex(),wherey());*/ + i = getche (); + col = wherex (); + col--; + fil = wherey (); + if (i == 0) { + /* //printf("dentro de i=0");*/ + a = getch (); + switch (a) { + case 72: { + gotoxy (col, fil - 1); +/* // printf("col= %d, fil= %d",col,fil);*/ + + /* // getch();*/ + + break; + + + } + + + case 80: + + + gotoxy (col, fil + 1); + + + break; + + + case 77: + + + gotoxy (col + 1, fil); + + + break; + + + case 75: + + + gotoxy (col - 1, fil); + + + break; + + + } + + +} + + + else + + + sw = 1; + + + } + + + printf ("fin"); + + + getch (); + + + fflush (stdin); + + + clrscr (); + + + + +} + + diff --git a/CPP/DAMAS.BAK b/CPP/DAMAS.BAK new file mode 100644 index 0000000..96298aa --- /dev/null +++ b/CPP/DAMAS.BAK @@ -0,0 +1,148 @@ + +#include +#include +#include +#include +#include + +int huge detectEGA(void); +void main(){ + int gdriver = DETECT, gmode, errorcode; + + gdriver = installuserdriver("svga256",detectEGA); + initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", grapherrormsg(errorcode)); + printf("Pulse cualquier tecla para finalizar..."); + getch(); + exit(1); + } + + MouseInit(); + MShowCursor(); + setcolor(1); + rectangle(-1,-1,640,480);setfillstyle(9,1);floodfill(2,2,1); + setcolor(15); + rectangle(288,88,612,412);rectangle(290,90,610,410); + int i=0; + for (i=1;i<9;i++) + line(290+(i*40),90,290+(i*40),410); + for (i=1;i<9;i++) + line(290,90+(i*40),610,90+(i*40)); + for (int y=90,con=1,con2=1;y<410;y=y+40,con2++) + for (int x=290;x<610;x=x+40,con++){ + if (con%2==0 && con2%2!=0) + setfillstyle(1,6); + else + if (con%2!=0 && con2%2==0) + setfillstyle(1,6); + else + setfillstyle(1,14); + floodfill(x+1,y+1,15); + } + for (y=110,con=1,con2=1;y<230;y=y+40,con2++) + for (i=310;i<610;i=i+40,con++) + if ((con%2==0 && con2%2!=0) || (con%2!=0 && con2%2==0)){ + setcolor(0);setfillstyle(1,0);circle(i,y,10);floodfill(i,y,0); + } + for (y=310,con=1,con2=6;y<410;y=y+40,con2++) + for (i=310;i<610;i=i+40,con++) + if ((con%2==0 && con2%2!=0) || (con%2!=0 && con2%2==0)){ + setcolor(15);setfillstyle(1,15);circle(i,y,10);floodfill(i,y,15); + } + + int sw=0,cursor=0,col=0,fil=0,a=0,color=6; + col=370;fil=210;setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38);rectangle(col+3,fil+3,col+37,fil+37); + + while(sw==0){ + cursor=getche(); + if (cursor!=13){ + setcolor(color);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38);rectangle(col+3,fil+3,col+37,fil+37); + } + if(cursor==0){ + a=getch(); + switch(a){ + case 72: + if (col>289 && col<571 && fil>89 && fil<371){ + fil=fil-40; + if (fil<89) + fil=fil+40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 80: + if (col>289 && col<571 && fil>89 && fil<371){ + fil=fil+40; + if (fil>371) + fil=fil-40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 77: + if (col>289 && col<571 && fil>89 && fil<371){ + col=col+40; + if (col>571) + col=col-40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 75: + if (col>289 && col<571 && fil>89 && fil<371){ + col=col-40; + if (col<289) + col=col+40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + } + } + else + if (cursor==13){ + int color2=0; + color2=getpixel(col+20,fil+20); + setcolor(color);setfillstyle(1,color);floodfill(col+20,fil+20,color); + circle(col+20,fil+20,color); + setcolor(8);setfillstyle(1,8);circle(col+22,fil+22,10); + floodfill(col+22,fil+22,8); + setcolor(color2);setfillstyle(1,color2);circle(col+18,fil+18,10); + floodfill(col+18,fil+18,color2); + col=370;fil=210;setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + else + sw=1; + } + getch(); + MouseClose(); + closegraph(); +} +/* detects EGA or VGA cards */ +int huge detectEGA(void) +{ + int driver, mode, sugmode = 0; + sugmode++; + + detectgraph(&driver, &mode); + if ((driver == EGA) || (driver == VGA)) + /* return suggested video mode number */ + return 1; + else + /* return an error code */ + return grError; +} \ No newline at end of file diff --git a/CPP/DAMAS.CPP b/CPP/DAMAS.CPP new file mode 100644 index 0000000..0b6e8d4 --- /dev/null +++ b/CPP/DAMAS.CPP @@ -0,0 +1,126 @@ + +#include +#include +#include +#include + +void main(){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "d:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", grapherrormsg(errorcode)); + printf("Pulse cualquier tecla para finalizar..."); + getch(); + exit(1); + } + setcolor(1); + rectangle(-1,-1,640,480);setfillstyle(9,1);floodfill(2,2,1); + setcolor(15); + rectangle(288,88,612,412);rectangle(290,90,610,410); + int i=0; + for (i=1;i<9;i++) + line(290+(i*40),90,290+(i*40),410); + for (i=1;i<9;i++) + line(290,90+(i*40),610,90+(i*40)); + for (int y=90,con=1,con2=1;y<410;y=y+40,con2++) + for (int x=290;x<610;x=x+40,con++){ + if (con%2==0 && con2%2!=0) + setfillstyle(1,6); + else + if (con%2!=0 && con2%2==0) + setfillstyle(1,6); + else + setfillstyle(1,14); + floodfill(x+1,y+1,15); + } + for (y=110,con=1,con2=1;y<230;y=y+40,con2++) + for (i=310;i<610;i=i+40,con++) + if ((con%2==0 && con2%2!=0) || (con%2!=0 && con2%2==0)){ + setcolor(0);setfillstyle(1,0);circle(i,y,10);floodfill(i,y,0); + } + for (y=310,con=1,con2=6;y<410;y=y+40,con2++) + for (i=310;i<610;i=i+40,con++) + if ((con%2==0 && con2%2!=0) || (con%2!=0 && con2%2==0)){ + setcolor(15);setfillstyle(1,15);circle(i,y,10);floodfill(i,y,15); + } + + int sw=0,cursor=0,col=0,fil=0,a=0,color=6; + col=370;fil=210;setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38);rectangle(col+3,fil+3,col+37,fil+37); + + while(sw==0){ + cursor=getche(); + if (cursor!=13){ + setcolor(color);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38);rectangle(col+3,fil+3,col+37,fil+37); + } + if(cursor==0){ + a=getch(); + switch(a){ + case 72: + if (col>289 && col<571 && fil>89 && fil<371){ + fil=fil-40; + if (fil<89) + fil=fil+40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 80: + if (col>289 && col<571 && fil>89 && fil<371){ + fil=fil+40; + if (fil>371) + fil=fil-40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 77: + if (col>289 && col<571 && fil>89 && fil<371){ + col=col+40; + if (col>571) + col=col-40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 75: + if (col>289 && col<571 && fil>89 && fil<371){ + col=col-40; + if (col<289) + col=col+40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + } + } + else + if (cursor==13){ + int color2=0; + color2=getpixel(col+20,fil+20); + setcolor(color);setfillstyle(1,color);floodfill(col+20,fil+20,color); + circle(col+20,fil+20,color); + setcolor(8);setfillstyle(1,8);circle(col+22,fil+22,10); + floodfill(col+22,fil+22,8); + setcolor(color2);setfillstyle(1,color2);circle(col+18,fil+18,10); + floodfill(col+18,fil+18,color2); + col=370;fil=210;setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + else + sw=1; + } + getch(); + closegraph(); +} diff --git a/CPP/DAMAS.~C b/CPP/DAMAS.~C new file mode 100644 index 0000000..8509840 --- /dev/null +++ b/CPP/DAMAS.~C @@ -0,0 +1,148 @@ + +#include +#include +#include +#include +#include + +int huge detectEGA(void); +void main(){ + int gdriver = DETECT, gmode, errorcode; + + gdriver = installuserdriver("egavga",detectEGA); + initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", grapherrormsg(errorcode)); + printf("Pulse cualquier tecla para finalizar..."); + getch(); + exit(1); + } + + MouseInit(); + MShowCursor(); + setcolor(1); + rectangle(-1,-1,640,480);setfillstyle(9,1);floodfill(2,2,1); + setcolor(15); + rectangle(288,88,612,412);rectangle(290,90,610,410); + int i=0; + for (i=1;i<9;i++) + line(290+(i*40),90,290+(i*40),410); + for (i=1;i<9;i++) + line(290,90+(i*40),610,90+(i*40)); + for (int y=90,con=1,con2=1;y<410;y=y+40,con2++) + for (int x=290;x<610;x=x+40,con++){ + if (con%2==0 && con2%2!=0) + setfillstyle(1,6); + else + if (con%2!=0 && con2%2==0) + setfillstyle(1,6); + else + setfillstyle(1,14); + floodfill(x+1,y+1,15); + } + for (y=110,con=1,con2=1;y<230;y=y+40,con2++) + for (i=310;i<610;i=i+40,con++) + if ((con%2==0 && con2%2!=0) || (con%2!=0 && con2%2==0)){ + setcolor(0);setfillstyle(1,0);circle(i,y,10);floodfill(i,y,0); + } + for (y=310,con=1,con2=6;y<410;y=y+40,con2++) + for (i=310;i<610;i=i+40,con++) + if ((con%2==0 && con2%2!=0) || (con%2!=0 && con2%2==0)){ + setcolor(15);setfillstyle(1,15);circle(i,y,10);floodfill(i,y,15); + } + + int sw=0,cursor=0,col=0,fil=0,a=0,color=6; + col=370;fil=210;setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38);rectangle(col+3,fil+3,col+37,fil+37); + + while(sw==0){ + cursor=getche(); + if (cursor!=13){ + setcolor(color);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38);rectangle(col+3,fil+3,col+37,fil+37); + } + if(cursor==0){ + a=getch(); + switch(a){ + case 72: + if (col>289 && col<571 && fil>89 && fil<371){ + fil=fil-40; + if (fil<89) + fil=fil+40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 80: + if (col>289 && col<571 && fil>89 && fil<371){ + fil=fil+40; + if (fil>371) + fil=fil-40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 77: + if (col>289 && col<571 && fil>89 && fil<371){ + col=col+40; + if (col>571) + col=col-40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + case 75: + if (col>289 && col<571 && fil>89 && fil<371){ + col=col-40; + if (col<289) + col=col+40; + color=getpixel(col+1,fil+1); + setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + break; + } + } + else + if (cursor==13){ + int color2=0; + color2=getpixel(col+20,fil+20); + setcolor(color);setfillstyle(1,color);floodfill(col+20,fil+20,color); + circle(col+20,fil+20,color); + setcolor(8);setfillstyle(1,8);circle(col+22,fil+22,10); + floodfill(col+22,fil+22,8); + setcolor(color2);setfillstyle(1,color2);circle(col+18,fil+18,10); + floodfill(col+18,fil+18,color2); + col=370;fil=210;setcolor(13);rectangle(col+1,fil+1,col+39,fil+39); + rectangle(col+2,fil+2,col+38,fil+38); + rectangle(col+3,fil+3,col+37,fil+37); + } + else + sw=1; + } + getch(); + MouseClose(); + closegraph(); +} +/* detects EGA or VGA cards */ +int huge detectEGA(void) +{ + int driver, mode, sugmode = 0; + sugmode++; + + detectgraph(&driver, &mode); + if ((driver == EGA) || (driver == VGA)) + /* return suggested video mode number */ + return 4; + else + /* return an error code */ + return grError; +} diff --git a/CPP/DAMAS2.BAK b/CPP/DAMAS2.BAK new file mode 100644 index 0000000..adeab57 --- /dev/null +++ b/CPP/DAMAS2.BAK @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include + +void main(){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", grapherrormsg(errorcode)); + printf("Pulse cualquier tecla para finalizar..."); + getch(); + exit(1); + } + setcolor(1); + rectangle(-1,-1,640,480);setfillstyle(9,1);floodfill(2,2,1); +// Pendiente 1/4 =80 + setcolor(15); + setlinestyle(0,1,3);line(80,430,560,430); + setlinestyle(0,1,1);line(80,430,160,110);line(560,430,480,110); + line(160,110,480,110); + line(320,430,320,110); + line(260,430,280,110);line(200,430,240,110);line(140,430,200,110); + line(380,430,360,110);line(440,430,400,110);line(500,430,440,110); + line(150,150,490,150); + line(160,192,500,192); +// setfillstyle(1,14);floodfill(475,112,15); + getch(); + closegraph(); +} \ No newline at end of file diff --git a/CPP/DAMAS2.CPP b/CPP/DAMAS2.CPP new file mode 100644 index 0000000..0e574c4 --- /dev/null +++ b/CPP/DAMAS2.CPP @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +void main(){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", grapherrormsg(errorcode)); + printf("Pulse cualquier tecla para finalizar..."); + getch(); + exit(1); + } + setcolor(1); + rectangle(-1,-1,640,480);setfillstyle(9,1);floodfill(2,2,1); +// Pendiente 1/4 =80 + setcolor(15); + setlinestyle(0,1,3);line(80,430,560,430); + setlinestyle(0,1,1);line(80,430,160,110);line(560,430,480,110); + line(160,110,480,110); + line(320,430,320,110); + line(260,430,280,110);line(200,430,240,110);line(140,430,200,110); + line(380,430,360,110);line(440,430,400,110);line(500,430,440,110); + line(150,150,490,150); + line(160,192,500,192); +// setfillstyle(1,14);floodfill(475,112,15); + getch(); + closegraph(); +} \ No newline at end of file diff --git a/CPP/DIBPRUE.CPP b/CPP/DIBPRUE.CPP new file mode 100644 index 0000000..92985e6 --- /dev/null +++ b/CPP/DIBPRUE.CPP @@ -0,0 +1,192 @@ +#include +#include + +char ventana (int ancho,int largo,int color_g,int color_borde,char titulo[], +int color_titulo,int posx,int posy); + +void main() { + int cabeza[5][7],pelo[2][7],piernad[5][9],soga[12][7]; + textbackground(0); + clrscr(); + ventana(80,24,7,1,"Juego del Ahorcado",14,1,1); + +// Pintar soga. + soga[0][3]='Û';soga[1][3]='Û';soga[2][3]='Û';soga[3][3]='Û';soga[4][3]='Û'; + soga[5][2]='Û';soga[5][4]='Û';soga[6][1]='Û';soga[6][5]='Û';soga[7][0]='Û'; + soga[7][6]='Û';soga[8][0]='Û';soga[8][6]='Û';soga[9][0]='Û';soga[9][6]='Û'; + soga[10][1]='Û';soga[10][5]='Û';soga[11][2]='Û';soga[11][3]='Û'; + soga[11][4]='Û'; + + for (int f=2,y=2;f<12;f++,y++) { + gotoxy(60,y); + for (int c=0;c<7;c++) { + if (soga[f][c]=='Û') { + textcolor(14); + cprintf ("%c",soga[f][c]); + } + else { + textcolor(7); + cprintf ("Û"); + } + } + } + +// pintar cabeza + cabeza[0][1]='Û';cabeza[0][2]='Û';cabeza[0][3]='Û';cabeza[0][4]='Û'; + cabeza[0][5]='Û';cabeza[1][0]='Û';cabeza[1][1]='Û';cabeza[1][2]='Û'; + cabeza[1][3]='Û';cabeza[1][4]='Û';cabeza[1][5]='Û';cabeza[1][6]='Û'; + cabeza[2][0]='Û';cabeza[2][1]='Û';cabeza[2][2]='Û';cabeza[2][3]='Û'; + cabeza[2][4]='Û';cabeza[2][5]='Û';cabeza[2][6]='Û'; + cabeza[3][1]='Û';cabeza[3][2]='Û';cabeza[3][3]='Û';cabeza[3][4]='Û'; + cabeza[3][5]='Û';cabeza[4][2]='Û';cabeza[4][3]='Û';cabeza[4][4]='Û'; + for (f=0,y=6;f<5;f++,y++) { + gotoxy(60,y); + for (int c=0;c<7;c++) { + if (cabeza[f][c]=='Û') { + textcolor(6); + cprintf ("%c",cabeza[f][c]); + } + else { + textcolor(14); + cprintf ("Û"); + } + } + } + +// Pintar pelo + pelo[0][0]='Û';pelo[0][1]='Û';pelo[0][2]='Û';pelo[0][3]='Û'; + pelo[0][4]='Û';pelo[0][5]='Û';pelo[0][6]='Û';pelo[1][0]='Û'; + pelo[1][6]='Û'; + for (f=0,y=5;f<2;f++,y++) { + gotoxy(60,y); + for (int c=0;c<7;c++) { + if (pelo[f][c]=='Û') { + textcolor(0); + cprintf ("%c",pelo[f][c]); + } + else { + textcolor(6); + cprintf ("Û"); + } + } + } +// Pintar cara alegre. + // Pintar ojos + textbackground(6);textcolor(0); + gotoxy (62,7);cprintf ("O"); + gotoxy (64,7);cprintf ("O"); + // Pintar nariz. + gotoxy(63,8);cprintf("U"); + // Pintar boca. + gotoxy(62,9);cprintf("À"); + gotoxy(64,9);cprintf("Ù"); + gotoxy(63,9);cprintf("-"); + +// Pintar cara triste. + // Pintar ojos + textbackground(6);textcolor(0); + gotoxy (62,7);cprintf ("*"); + gotoxy (64,7);cprintf ("*"); + // Pintar nariz. + gotoxy(63,8);cprintf("U"); + // Pintar boca. + gotoxy(62,9);cprintf("+"); + gotoxy(64,9);cprintf("+"); + gotoxy(63,9);cprintf("+"); + +// Pintar cuerpo. + ventana(11,5,6,6,"",6,58,12); + +// Pintar pierna. + piernad[0][0]='Û';piernad[0][1]='Û';piernad[0][2]='Û';piernad[0][3]='Û'; + piernad[1][1]='Û';piernad[1][2]='Û';piernad[1][3]='Û';piernad[1][4]='Û'; + piernad[2][2]='Û';piernad[2][3]='Û';piernad[2][4]='Û';piernad[2][5]='Û'; + piernad[3][3]='Û';piernad[3][4]='Û';piernad[3][5]='Û';piernad[3][6]='Û'; + piernad[4][4]='Û';piernad[4][5]='Û';piernad[4][6]='Û';piernad[4][7]='Û'; + // Derecha + for (f=0,y=17;f<5;f++,y++) { + gotoxy(64,y); + for (int c=0;c<9;c++) { + if (piernad[f][c]=='Û') { + textcolor(6); + cprintf ("%c",piernad[f][c]); + } + else { + textcolor(7); + cprintf ("Û"); + } + } + } + + // Izquierda. + for (f=0,y=17;f<5;f++,y++) { + gotoxy(54,y); + for (int c=8;c>=0;c--) { + if (piernad[f][c]=='Û') { + textcolor(6); + cprintf ("%c",piernad[f][c]); + } + else { + textcolor(7); + cprintf ("Û"); + } + } + } + +// Pintar brazos. + // Derecho + for (f=0,y=12;f<4;f++,y++) { + gotoxy(69,y); + for (int c=0;c<9;c++) { + if (piernad[f][c]=='Û') { + textcolor(6); + cprintf ("%c",piernad[f][c]); + } + else { + textcolor(7); + cprintf ("Û"); + } + } + } + + // Izquierda. + for (f=0,y=12;f<4;f++,y++) { + gotoxy(49,y); + for (int c=8;c>=0;c--) { + if (piernad[f][c]=='Û') { + textcolor(6); + cprintf ("%c",piernad[f][c]); + } + else { + textcolor(7); + cprintf ("Û"); + } + } + } + + +getch(); +} + +char ventana (int ancho,int largo,int color_g,int color_borde,char titulo[80], +int color_titulo,int posx,int posy) { + int x,y,cony,conx; + char dib; + dib='Û'; + for (cony=0,y=posy;cony +#include +#include +#include +#include +#include +#include +#include +#include + +// ************************************************************************** +// **** **** +// **** Declaraci¢n de las Estructuras **** +// **** **** +// ************************************************************************** + +struct def{ // Estructura en la que se guarda la palabra + char palabra[20]; // y la definici¢n de la misma. + char definicion[100]; + struct def *sig; +}; + +struct letra3{ // Estructura que forma la tercera letra indexada + char l3; // del  rbol. + struct letra3 *sig; + struct def *lista; +}; +struct letra2{ // Estructura que forma la segunda letra indexada + char l2; // del  rbol. + struct letra2 *sig; + struct letra3 *nivel3; +}; +struct letra1{ // Estructura que forma la primera letra indexada + char l1; // del  rbol. + struct letra1 *sig; + struct letra2 *nivel2; +}; +struct temporal{ // Para que no de problemas a la hora de grabarlo y + char palabra[20]; // cargarlo del fichero. + char definicion[100]; +}; +// NO PUEDEN SER TODAS LAS ESTRUCTURAS DE LAS LETRAS IGUALES, YA QUE CUANDO +// AVANZAMOS EN PROFUNDIDAD POR EL µRBOL, LAS ESTRUCTURAS A LAS QUE +// APUNTAN SON DIFERENTES. + + +// ************************************************************************** +// **** **** +// **** Inizializaci¢n de Funciones **** +// **** **** +// ************************************************************************** + +struct letra1* inicializar(); // Inicializa el  rbol del diccionario. +void cargar_diccio(struct letra1 *); // Carga el diccionario del fichero. +void guardar_arbol(struct letra1 *);// Guarda el diccio en el fichero. +void nueva_palabra(struct letra1 *); // Agrega una nueva palabra al diccio. +void modif_palabra(struct letra1 *); // modif la def de una palabra del diccio + +void listar(struct letra1*,int);//Lista las palabras del diccio. +void listar_sen(struct letra1*, int, char*, char [10][20]); // Lista sensible. +void imprime_def(char *);// Imprime la def con el algor¡tmo de abrir l¡neas. + +void limpiar_nodo(struct def **); // limpia el nodo reservado. +void limpiar(struct temporal *); // limpia la estructura auxiliar. + +struct def* buscar(struct letra1 *, struct temporal *); // busca la palabra en el diccio. +void buscar_palabra(struct letra1 *,int); // El padre de buscar con sus ventanas. +void busca_sen(struct letra1 *);// busca por las tres primeras letras. + +int huge detectEGA(void); // devuelve la resoluci¢n de la pantalla. +void checkerrors(void); // mira si hay fallos al inizializar el modo gr fico. + +void rectangulo(int); // dibuja el rectangulo de los botones. +void menu(); // pinta el menu general. +void base(); // pinta el fondo con t¡tulo y barra inferior. +void menu_buscar(); // pinta el menu de b£squeda. +void acerca_de(); // informaci¢n de los creadores. + +void intro_letras(int, int, char[], int, int, int, int, int); // introducci¢n la palabra. +void introdef(int, int, char[], int, int, int, int, int);// intro al definici¢n. +void intro_sen(int, int, char[], int, int, int);// intro las tres 1¦ letras de la palabra. + + +// ************************************************************************** +// **** **** +// **** Variables Globales **** +// **** **** +// ************************************************************************** + +struct temporal fichero; // tiene temporalmente los datos de un nodo. + + +// ************************************************************************** +// **** **** +// **** El cuerpo del Programa **** +// **** **** +// ************************************************************************** + +void main(){ +// ************************************************************************** +// **** Variables Locales al Main **** +// ************************************************************************** +// Bienvenido al mundo de los punteros :-). + struct letra1 *diccio; // Es el puntero m s grande. + int sw=1, pos=1; // el sw para saber cuando elige una opci¢n y pos la + int tecla=0; // posici¢n en el menu, tecla son los cursores. + +// ************************************************************************** +// **** Inizializaci¢n del modo gr fico **** +// ************************************************************************** + installuserdriver("SVGA256", detectEGA); // instala el controlador de 256c. + int Gd = DETECT, Gm; + checkerrors(); // mira a ver si hay errores. + initgraph(&Gd, &Gm, "c:\\tc\\bgi");// inicializa el modo gr fico. + checkerrors(); // mira a ver si hay errores. + +// ************************************************************************** +// **** El programa **** +// ************************************************************************** + base(); // fondo y t¡tulo. + settextstyle(2,0,5); + ventana(125,200,475,300,"Cargando...",0,0);// dibujamos una ventana. + boton(133,265,467,275,1,"",0,0); + setcolor(0); + settextstyle(2,0,5); + outtextxy(136,235,"Cargando el diccionario, espere porfavor...");// texto de la ventana. + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Cargando..."); // informaci¢n de la barra inferior. + diccio=inicializar();//Inicializamos el  rbol del diccionario. + cargar_diccio(diccio);// carga el diccio del fichero. + + base();// limpiamos pantalla + menu();// ponemos el menu general. + rectangulo(pos);// el recuadro de los botones + settextstyle(2,0,4); + outtextxy(30,460,"Elige una opci¢n del men£.");// informaci¢n de la barra inferior. + while (sw){ // bucle general del menu general. + tecla=getch();// a ver que pulsa + if (tecla==0){// es tecla especial. + tecla=getch();// a ver cual es + switch(tecla){ // que flecha es + case 72: // flecha arriba. + if (pos!=1){// no est  en el primer boton + menu();// el menu principal + pos--;// subimos por el menu + setcolor(0);rectangulo(pos);// cambia el rectangulo + }// fin if primer boton + else{// est  en el primer boton + menu();// lo dibujamos igual + pos=5;// se va al £ltimo boton + setcolor(0);rectangulo(pos);// donde esta el rectangulo + }// fin else + break;// le rompemos al switch + case 80: // flecha abajo. + if (pos!=5){// si no est  en el £ltimo. + menu();// ¨qu‚ pintamos? + pos++;// bajamos por los botones + setcolor(0);rectangulo(pos);// idem + }// fin if + else{// est  en el £ltimo + menu();// que pasa + pos=1;// le subimos al primero + setcolor(0);rectangulo(pos);// eeeeee + }//fin else + break;// que quiebro + }// fin del switch tecla + switch(pos){// miramos en que boton esta + case 1:// Buscar palabra. + boton(0,450,getmaxx(),getmaxy(),0,"",0,0);// limpiamos barra inferior + settextstyle(2,0,4);setcolor(0);// informaci¢n inferior. + outtextxy(30,460,"B£squeda de una palabra mediante varios m‚todos."); + break;// le ha roto + case 2:// Introducir nueva palabra. + boton(0,450,getmaxx(),getmaxy(),0,"",0,0);// igual no idem + settextstyle(2,0,4);setcolor(0);// parecidillo + outtextxy(30,460,"Introducci¢n de palabras nuevas para la base de datos del diccionario."); + break;// toma y van cuatro + case 3: // Modificacion de palabras + boton(0,450,getmaxx(),getmaxy(),0,"",0,0);// lo pispo + settextstyle(2,0,4);setcolor(0);// lo que + outtextxy(30,460,"Modificaci¢n de la definici¢n de una palabra de la base de datos del diccionario."); + break;// es un poco fragil + case 4:// Acerca de... + boton(0,450,getmaxx(),getmaxy(),0,"",0,0);// lo pispo de lo pispo + settextstyle(2,0,4);setcolor(0);// que donde trabajas + outtextxy(30,460,"Informaci¢n de los creadores del programa."); + break;// se ha hecho pedacitos + case 5:// Salir. + boton(0,450,getmaxx(),getmaxy(),0,"",0,0);// lo pispo de lo pispo... + settextstyle(2,0,4);setcolor(0);// escribiendo comentarios + outtextxy(30,460,"Salir del programa.");// informaci¢n corta :-) + break;// no me quedan calificativos, es lo peor. + }// fin del switch de la informaci¢n inferior. + }// fin del if de la tecla especial + else{// no es especial, bua! + if (tecla==13){// se ha cansado de moverse por los botones + switch(pos){// a ver.. + case 1: // buscar una palabra. + base();// limpiando... + menu_buscar();// un nuevo men£ + int sw2=1, donde=1;// necesitamos ayuda + int opcion=0;// un poquito m s + rectangulo(donde);// adonde estamos en los botones + setcolor(0); + settextstyle(2,0,4);// informaci¢n inferior. + outtextxy(30,460,"Elige una opci¢n del men£ de b£squeda."); + while (sw2){// bucle del menu secundario. + opcion=getch();// aver que nos pulsa aqu¡ + if (opcion==0){// es especial! + opcion=getch();// cual es? + switch(opcion){// vamos a descubrirlo + case 72: // flecha arriba. + if (donde!=1){// igual que el principal + menu_buscar(); + donde--; + setcolor(0);rectangulo(donde); + } + else{ + menu_buscar(); + donde=4; + setcolor(0);rectangulo(donde); + } + break; + case 80: // flecha abajo. + if (donde!=4){ + menu_buscar(); + donde++; + setcolor(0);rectangulo(donde); + } + else{ + menu_buscar(); + donde=1; + setcolor(0);rectangulo(donde); + } + break; + }// fin del switch opcion + switch(donde){// a ver que informaci¢n imprimimos? + case 1:// Buscar palabra. + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0);// todo igualisimo que + outtextxy(30,460,"B£squeda de una palabra mediante la introducci¢n de la misma y se muestra la definici¢n."); + break; + case 2:// Busqueda sensible + boton(0,450,getmaxx(),getmaxy(),0,"",0,0);// el general. + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Introducci¢n de las tres primeras letras y elegir de la lista la palabra que se quiera."); + break; + case 3:// Acerca de... + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Informaci¢n de los creadores del programa. Por si en el men£ general no lo hab‚is visto."); + break; + case 4:// Volver. + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Vuelve al men£ general del programa."); + break; + }// fin del switch donde + }// fin de la tecla especial + else{// se nos cansa + if (opcion==13){// a tomado su primera decisi¢n + switch(donde){// a donde la ha tomado? + case 1: // Buscar palabra. + buscar_palabra(diccio,0);// buscamos la palabra. + getch();// e ver si le da tiempo de ver la definici¢n. + base();menu_buscar();rectangulo(donde);// repintamos la + setcolor(0);settextstyle(2,0,4);// situaci¢n anterior. + outtextxy(30,460,"Elige una opci¢n del men£ de b£squeda."); + break; + case 2: // Busqueda sensible a teclado. + busca_sen(diccio);// buscamos con mucha sensibilidad. + base();menu_buscar();rectangulo(donde);// reconstruimos + setcolor(0);settextstyle(2,0,4); + outtextxy(30,460,"Elige una opci¢n del men£ de b£squeda."); + break; + case 3: // Acerca de... + acerca_de();// ­LE INTERESAMOS! ¢ se a confundido? + base();menu_buscar();rectangulo(donde);// reconstructor + settextstyle(2,0,4); + outtextxy(30,460,"Elige una opci¢n del men£."); + break; + case 4: // volver. + base();// volviendo para el yeneral + menu(); + rectangulo(pos); + settextstyle(2,0,4); + outtextxy(30,460,"Elige una opci¢n del men£."); + sw2=0; + break; + }// Fin del switch(donde). + }// Fon del if (opcion==13). + }// Fin del else tocho. + }// Fin del while(sw2). + break;// le rompemos que ya ha tenido bastante con est  opci¢n. + case 2: // a¤adir una palabra. + nueva_palabra(diccio);// a ver que nos mete el pill¡n + base();menu();rectangulo(pos);// reconstructor 2 el retonno + settextstyle(2,0,4); + outtextxy(30,460,"Elige una opci¢n del men£."); + break; + case 3: // modificar una palabra. + modif_palabra(diccio);// esas manazas!!!! + base();menu();rectangulo(pos);// reconstructor 3 quiz s vuelva... + settextstyle(2,0,4); + outtextxy(30,460,"Elige una opci¢n del men£."); + break; + case 4: // acerca de... + acerca_de();// ­­SIII, LE INTERESAMOS DE VERDAD!!! + base();menu();rectangulo(pos);// reconstructor 4 y continuar ... + settextstyle(2,0,4); + outtextxy(30,460,"Elige una opci¢n del men£."); + break; + case 5: // salir + guardar_arbol(diccio);// vamos a guardar los cambios. + sw=0;// nos las piramos. + break; + }// fin del switch(pos) + }// fin del if (tecla=13) + }// fin del else de tecla=0. + }// fin del while(sw) + closegraph();// se acab¢ el chiringuito. +}// fin del main. + + +// ************************************************************************** +// **** **** +// **** Inicializar µrbol **** +// **** **** +// ************************************************************************** + +struct letra1* inicializar(){ +// Variables locales a la funci¢n. + char letra=97;//Es la a. + struct letra1 *dic,*p1,*aux; // Un mar de punteros para ver si lo conseguimos + struct letra2 *p2,*aux2; // inicializar bien. :-/ + struct letra3 *p3,*aux3; // Dic es el amago de boss, px es el que tiene + // el nuevo nodo, y aux/auxX tiene el £ltimo + // nodo insertado en cada nivel. + +// Bucle de la primera letra. + for(;letra<123;letra++){//La 90 es la z. + if ((p1=(struct letra1 *) malloc(sizeof(struct letra1)))==NULL){ + closegraph(); + printf("No hay memoria suficiente.");getch();// Mal rollo. + exit(1); + } + else{ + if (letra==97){ //Solamente la primera vez, ya que es un caso especial. + p1->l1=letra;p1->sig=NULL; + p1->nivel2=NULL; + dic=p1;aux=p1; // Hay que direcionar al boss. + } + else{ // El resto de los casos son iguales. + p1->l1=letra;p1->sig=NULL; + p1->nivel2=NULL; + aux->sig=p1; + aux=aux->sig; + } +// Bucle de la segunda letra. + for (char letra2=97;letra2<123;letra2++){ + if ((p2=(struct letra2 *) malloc(sizeof(struct letra2)))==NULL){ + closegraph(); + printf("No hay memoria suficiente.");getch();// Mal rollito. + exit(1); + } + else{ + if (letra2==97){ // Igual que el anterior. + p2->l2=letra2;p2->sig=NULL; + p2->nivel3=NULL; // Aqu¡ igual que el boss, pero con la letra + aux->nivel2=p2;aux2=p2; // correspondiente. + } + else{ // Igual que el anterior. + p2->l2=letra2;p2->sig=NULL; + p2->nivel3=NULL; + aux2->sig=p2; + aux2=aux2->sig; + } +// Bucle de la tercera letra. + for (char letra3=97;letra3<123;letra3++){ + if ((p3=(struct letra3 *) malloc(sizeof(struct letra3)))==NULL){ + closegraph(); + printf("No hay memoria suficiente.");// De mal en peor. + getch(); + exit(1); + } + else{ + if (letra3==97){// Por el mismo motivo que los anteriores. + p3->l3=letra3;p3->sig=NULL; + p3->lista=NULL; // Igual que 2, pero con la letra + aux2->nivel3=p3;aux3=p3; // correspondiente. + } + else{// Idem. + p3->l3=letra3;p3->sig=NULL; + p3->lista=NULL; + aux3->sig=p3; + aux3=aux3->sig; + } + } + }//Fin del bucle de la tercera letra. + } + }// Fin del bucle de la segunda letra. + } + }// Fin del bucle de la primera letra. + return(dic); // Devolvemos el amago de boss, par aque el boss se quede con + // la direcci¢n del  rbol. +}// Fin de la funci¢n inicializar el  rbol. + + +// ************************************************************************** +// **** **** +// **** Listado del µrbol **** +// **** **** +// ************************************************************************** + +void listar(struct letra1 *dic, int max){ // Lista las n palabras especificadas + int con=0, y=245; + setcolor(0);settextstyle(2,0,4); + for(struct letra1 *n1=dic;n1!=NULL;n1=n1->sig){ + for (struct letra2 *n2=n1->nivel2;n2!=NULL;n2=n2->sig){ + for (struct letra3 *n3=n2->nivel3;n3!=NULL;n3=n3->sig){ + if (n3->lista!=NULL) + for (struct def *n4=n3->lista;n4!=NULL && max>con;n4=n4->sig,con++, + y+=12){ + outtextxy(200,y,n4->palabra); + } + } + } + } +}// fin de la funci¢n listar. + +void listar_sen(struct letra1 *dic, int max, char *letra, + char lista[10][20]){ // Lista las que sean = que las 3 1¦ letras + int con=0, y=245; + struct letra1 *n1=NULL; + struct letra2 *n2=NULL; + struct letra3 *n3=NULL; + setcolor(0);settextstyle(2,0,4); + for(n1=dic;n1!=NULL && n1->l1!=letra[0];n1=n1->sig){}// buscamos la 1¦ + n2=n1->nivel2;// pasamos a la segunda + if (letra[1]!=NULL)// a ver si existe + for(;n2!=NULL && n2->l2!=letra[1];n2=n2->sig){}// la buscamos la 2¦ + n3=n2->nivel3;// pasamos a la tercera + if (letra[2]!=NULL)// a ver si existe + for(;n3!=NULL && n3->l3!=letra[2];n3=n3->sig){}// buscamos la 3¦ + while (max>con && n1!=NULL){// para imprimir las que entran en el cuadro. + for(;n1!=NULL;n1=n1->sig){ + if (y!=245 || letra[1]==NULL)// por si se acaban los de una letra y hay que seguir. + n2=n1->nivel2; + for (;n2!=NULL;n2=n2->sig){ + if (y!=245 || letra[2]==NULL)// idem + n3=n2->nivel3; + for (;n3!=NULL;n3=n3->sig){ + if (n3->lista!=NULL) + for (struct def *n4=n3->lista;n4!=NULL && max>con;n4=n4->sig,con++, + y+=12){ + if(y==245){// si es la primera palabra le pintamos el fondo en azul. + setcolor(1); + rectangle(195,y,400,y+11); + setfillstyle(1,1);floodfill(201,y+1,1); + setcolor(30);outtextxy(200,y,n4->palabra); + setcolor(0); + } + else// si no no tiene derecho. + outtextxy(200,y,n4->palabra); + strcpy(lista[con],n4->palabra);// la copiamos a la lista. + } + }// fines de todo lo que se a abierto alguna vez + } + } + } +}// fin de la funci¢n listar_sen. + +void imprime_def(char *def){ // imprime la definici¢n con su algor¡tmo. + char aux[2];aux[1]=NULL;// la letra que se pinta + int xaux=200, yaux=245;// las posiciones + settextstyle(2,0,4);setcolor(0); + for (int pos=0;pos<=37 && def[pos]!=NULL;// primera l¡nea + pos++,xaux+=6){ + aux[0]=def[pos]; + outtextxy(xaux,yaux,aux); + } + if (def[pos]!=NULL){// si no se ha acabado + yaux=yaux+12;xaux=200;// siguiente l¡nea + for (;pos<=75 && def[pos]!=NULL;pos++,xaux+=6){// 2¦ l¡nea + aux[0]=def[pos]; + outtextxy(xaux,yaux,aux); + } + } + if (def[pos]!=NULL){// idem + yaux=yaux+12;xaux=200;// idem + for (;pos<=100 && def[pos]!=NULL;pos++,xaux+=6){// 3¦ l¡nea + aux[0]=def[pos]; + outtextxy(xaux,yaux,aux); + } + } +}// fin de la funci¢n imprimir definici¢n. + +void limpiar_nodo(struct def **puntero){// limpia el nodo reservado por si + for(int n=0;n<20;n++) + (*puntero)->palabra[n]=NULL; + for (n=0;n<100;n++) + (*puntero)->definicion[n]=NULL; +}// fin de la funci¢n limpiar nodo. + +void limpiar(struct temporal *p){// limpia la estructura multiusos. + for(int n=0;n<20;n++) + p->palabra[n]=NULL; + for (n=0;n<100;n++) + p->definicion[n]=NULL; +}// fin de la funci¢n limpiar la estructura temporal. + +void cargar_diccio(struct letra1 *dic){// cargamos el diccionario. + FILE *f=NULL, *aux=NULL;// los ficheros que necesitamos. + int con=0, x=0, veces=0, numero=0, cuantos=0, conaux=0;// para el algor¡tmo de los cuadraditos del comienzo. + if ((f=fopen("k:\\files\\diccio.bsd","r+b"))!=NULL){// abriendo + aux=fopen("k:\\files\\diccio.cfg","r+b");//idem + struct def *p=NULL,*help4=NULL;// lo necesitamos + struct letra1 *help1=NULL; + struct letra2 *help2=NULL; + struct letra3 *help3=NULL; + fread(&con,2,1,aux);// leemos cuantas palabras hay en el diccio + fclose(aux);// se acab¢ con este fichero. + fseek(f,25,0);// nos saltamos el encabezado + limpiar(&fichero);// limpieza + fread(&fichero,sizeof(struct temporal),1,f);// leemos el primer registro. + if(con==1 || con==0){// si solo hay una o cero palabras + cuantos=14; + for(veces=cuantos,x=136;x+8<464 && veces>0;x+=11,veces--) + icon11(x,267);// pintamos los cuadraditos + delay(500);// espera un poquito. + } + else{// tiene m s + numero=28/con;// a ver cuantos cuadrados hay que pintar + if (numero==0){// es m s que el m ximo de los cuadrados + numero=con/28;// cuanto m s + conaux=numero;// cuantos registros tienen que pasar para pintar uno + cuantos=1;// los pintamos de uno en uno + } + else{// no es mas del m ximo + conaux=1;cuantos=numero;// tiene que pasar un registro y se pintan x + } + x=136;// la posici¢n donde empieza a pintar + } + while(!feof(f)){// mientras que no se acabe el fichero + if ((p=(struct def *) malloc(sizeof(struct def)))==NULL){ + closegraph();// recogemos el chiringuito que viene la poli. + printf("No hay memoria suficiente.");getch();// Mal rollo. + exit(1);// nos vamos por patas + } + else{ + limpiar_nodo(&p);// limpiamos el nuevo nodo. + strcpy(p->palabra,fichero.palabra);// copiando del temporal al nuevo + strcpy(p->definicion,fichero.definicion);// idem + p->sig=NULL;// no tienes siguiente + help1=dic;// no toquemos el diccionario + for(;help1->l1!=p->palabra[0];help1=help1->sig){}// buscamos la 1¦ + help2=help1->nivel2; + for(;help2->l2!=p->palabra[1];help2=help2->sig){}// la 2¦ + help3=help2->nivel3; + for(;help3->l3!=p->palabra[2];help3=help3->sig){}// la 3¦ + if (help3->lista==NULL){// no hay palabras + help3->lista=p;help4=p;p->sig=NULL;// eres la primera palabra + } + else{// hay m s palabras + help4=help3->lista; + if (strcmp(p->palabra,help4->palabra)>0){// comparando... + for(;help4->sig!=NULL && strcmp(p->palabra,(help4->sig)->palabra)>0; + help4=help4->sig){}// encontrando su posici¢n... + p->sig=help4->sig;// enlazando... + help4->sig=p;help4=help4->sig; + } + else{// sitio encontrado + p->sig=help4;help3->lista=p;help4=help3->lista;// enlazando... + } + } + } + limpiar(&fichero);// limpiando la temporal + fread(&fichero,sizeof(struct temporal),1,f);// nuevo registro. + conaux--;// ya hemos le¡do uno + if (conaux==0){// nos toca pintar + for(veces=cuantos;x+8<464 && veces>0;x+=11,veces--) + icon11(x,267);// pintando... + delay(250);// esperamos + if (28/con==0)// reconstrucci¢n del contador + conaux=numero; + else + conaux=1; + } + }// fin del while final de fichero. + if (x+8<464){// si nos falta por pintar y ya hemos terminado. + for(;x+8<464;x+=11) + icon11(x,267);// lo pintamos + } + } + fclose(f);// cerramos el fichero + delay(500);// mira que binito a quedado el comienzo. +}// fin de la funci¢n cargar diccionario. + +void nueva_palabra(struct letra1 *dic){// introducir nueva letra + struct letra1 *aux=NULL;//Puntero auxiliar del tipo 1, dic es el semiboss. + struct letra2 *aux2=NULL;//Puntero auxiliar del tipo 2. Y ya van 3 :-(. + struct letra3 *aux3=NULL;//Puntero auxiliar del tipo 3. Son 4 :-|. + struct def *p4=NULL, *aux4=NULL;//Punteros auxiliares del tipo 4. + if ((p4=(struct def *) malloc(sizeof(struct def)))==NULL){ + closegraph();// recogiendo... + printf("No hay memoria suficiente. El programa debe terminar.");getch(); + exit(1);// Mal rollo. + } + else{ + limpiar_nodo(&p4);// limpiando... + limpiar(&fichero); + + base(); // limpiamos pantalla + settextstyle(2,0,5); + ventana(75,125,550,390,"Nueva palabra",0,0); + setcolor(0); + outtextxy(100,190,"Palabra:"); + boton(190,190,420,210,1,"",0,30); + setcolor(0); + outtextxy(100,240,"Definici¢n:"); + boton(190,240,450,370,1,"",0,28); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Introduce la palabra (longitud m xima 20 letras)."); + icon2(85,193); + intro_letras(200,195,fichero.palabra,19,0,2,4,30);// introduce la palabra + strlwr(fichero.palabra); + boton(190,190,420,210,1,"",0,28); + setcolor(0); + outtextxy(200,195,fichero.palabra); + if (buscar(dic,&fichero)==NULL){// si no est  + boton(190,240,450,370,1,"",0,30); + icon8(85,193); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Introduce la definici¢n de la palabra (longitud m xima 100 caracteres)."); + icon2(85,243); + introdef(200,245,fichero.definicion,100,0,2,4,30);// introduce la def + icon8(85,243); + + strlwr(fichero.palabra);// la copiamos en min£sculas + strcpy(p4->palabra,fichero.palabra);//copiando... + strcpy(p4->definicion,fichero.definicion); + p4->sig=NULL; + aux=dic; + for(;aux->l1!=p4->palabra[0];aux=aux->sig){}// la colocamos + aux2=aux->nivel2; + for(;aux2->l2!=p4->palabra[1];aux2=aux2->sig){} + aux3=aux2->nivel3; + for(;aux3->l3!=p4->palabra[2];aux3=aux3->sig){} + if (aux3->lista==NULL){ + aux3->lista=p4;aux4=p4;p4->sig=NULL; + } + else{ + aux4=aux3->lista; + if (strcmp(p4->palabra,aux4->palabra)>0){ + for(;aux4->sig!=NULL && strcmp(p4->palabra,(aux4->sig)->palabra)>0; + aux4=aux4->sig){} + p4->sig=aux4->sig; + aux4->sig=p4;aux4=aux4->sig; + } + else{ + p4->sig=aux4;aux3->lista=p4;aux4=aux3->lista; + } + } + } + else{// ya existe al palabra + sound(1000);delay(50);nosound(); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + icon10(5,455); + settextstyle(2,0,4);setcolor(4); + outtextxy(30,460,"La palabra introducida ya existe. Pulse ENTER para volver al men£."); + free(p4);getch(); + } + } +}// fin de la funci¢n de la nueva palabra. + +void modif_palabra(struct letra1 *dic){// midificamos la definici¢n. + struct letra1 *aux=NULL;//Puntero auxiliar del tipo 1, dic es el semiboss. + struct letra2 *aux2=NULL;//Puntero auxiliar del tipo 2. Y ya van 3 :-(. + struct letra3 *aux3=NULL;//Puntero auxiliar del tipo 3. Son 4 :-|. + struct def *p4=NULL, *aux4=NULL;//Punteros auxiliares del tipo 4. + buscar_palabra(dic,1);// la buscamos la palabra. + if ((p4=buscar(dic,&fichero))!=NULL){// si est  la palabra + int resp=0;// la respuesta + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Pulse ENTER para modificar la definici¢n o ESC para volver al men£."); + while(resp!=27 && resp!=13)// mientra no se ESC o ENTER + resp=getch(); + if (resp==13){// es enter + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Introduce la nueva definici¢n de la palabra (longitud m xima 100 caracteres)."); + char tmp[20]={NULL}; + boton(190,190,420,210,1,"",0,28); + boton(190,240,450,370,1,"",0,30); + setcolor(0); + outtextxy(200,195,fichero.palabra); + strcpy(tmp,fichero.palabra);// le sacamos de paseo a la palabra + limpiar(&fichero); + strcpy(fichero.palabra,tmp);// vuelve a casa + icon2(85,243); + introdef(200,245,fichero.definicion,100,0,2,4,30);// introduce la def + + strlwr(fichero.palabra);// idem todo el bloque + strcpy(p4->palabra,fichero.palabra); + p4->sig=NULL; + aux=dic; + for(;aux->l1!=p4->palabra[0];aux=aux->sig){} + aux2=aux->nivel2; + for(;aux2->l2!=p4->palabra[1];aux2=aux2->sig){} + aux3=aux2->nivel3; + for(;aux3->l3!=p4->palabra[2];aux3=aux3->sig){} + if (aux3->lista==NULL){ + aux3->lista=p4;aux4=p4;p4->sig=NULL; + } + else{ + aux4=aux3->lista; + if (strcmp(p4->palabra,aux4->palabra)!=0){ + for(;aux4!=NULL && strcmp(p4->palabra,aux4->palabra)!=0; + aux4=aux4->sig){} + strcpy(aux4->definicion,fichero.definicion);// solo copiamos la nueva def + } + else{ + strcpy(aux4->definicion,fichero.definicion);// solo copiamos la nueva def + }//fin else palabra = + }// fin else lista =null + }// fin if resp=13 + }// fin if busca=1 +}// fin de la funci¢n modificar definici¢n + +struct def* buscar(struct letra1 *dic, struct temporal *cad){// busca una palabra + + struct letra1 *aux=NULL;//Puntero auxiliar del tipo 1, dic es el semiboss. + struct letra2 *aux2=NULL;//Puntero auxiliar del tipo 2. Y ya van 3 :-(. + struct letra3 *aux3=NULL;//Puntero auxiliar del tipo 3. Son 4 :-|. + struct def *aux4=NULL;//Punteros auxiliares del tipo 4. + int sw=0; + + aux=dic; + for(;aux->l1!=cad->palabra[0];aux=aux->sig){}// la busca + aux2=aux->nivel2; + for(;aux2->l2!=cad->palabra[1];aux2=aux2->sig){} + aux3=aux2->nivel3; + for(;aux3->l3!=cad->palabra[2];aux3=aux3->sig){} + if (aux3->lista==NULL){// no est  + sw=0; + } + else{// puede que est‚ + aux4=aux3->lista; + if (strcmp(cad->palabra,aux4->palabra)!=0){ + for(;aux4->sig!=NULL && strcmp(cad->palabra,aux4->palabra)!=0; + aux4=aux4->sig){} + if (strcmp(cad->palabra,aux4->palabra)==0){// est  + strcpy(cad->definicion,aux4->definicion); + sw=1; + } + else// falsa alarma + sw=0; + } + else{// est  + strcpy(cad->definicion,aux4->definicion); + sw=1; + } + } + if(sw) + return(aux4);// donde est  + else + return(NULL);// no est  +}// fin de la funci¢n buscar. + +void buscar_palabra(struct letra1 *dic,int op){// funci¢n pader de buscar. + limpiar(&fichero); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + if (op==0){// la opci¢n de buscar. + outtextxy(30,460,"Introduce la palabra a buscar (longitud m xima 20 letras)."); + settextstyle(2,0,5); + ventana(75,125,550,390,"Buscar una palabra",0,0); + } + if (op==1){// la opci¢n de modificar + outtextxy(30,460,"Introduce la palabra a modificar (longitud m xima 20 letras)."); + settextstyle(2,0,5); + ventana(75,125,550,390,"Modificar una palabra",0,0); + } + setcolor(0); + outtextxy(100,190,"Palabra:"); + boton(190,190,420,210,1,"",0,30); + setcolor(0); + outtextxy(100,240,"Definici¢n:"); + boton(190,240,450,370,1,"",0,28); + icon2(85,193); + intro_letras(200,195,fichero.palabra,19,0,2,4,30); + strlwr(fichero.palabra); + icon8(85,193); + if(buscar(dic,&fichero)!=NULL){// existe la palabra + imprime_def(fichero.definicion); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + if (op==0)// opci¢n buscar + outtextxy(30,460,"Para volver al menu de b£squeda pulse una tecla."); + } + else{// no est  la palabra + setcolor(0);settextstyle(2,0,4); + outtextxy(200,245,"La palabra introducida no est  en la base"); + outtextxy(200,257,"de datos del diccionario."); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Para introducir la palabra, seleccione nueva palabra en el men£ general."); + } +}// fin de la funci¢n buscar palabra. + +void busca_sen(struct letra1 *dic){// busca las tres primeras letras + char cad[2];cad[0]=NULL;cad[1]=NULL;// la letra en s¡ + char lista[10][20]={NULL};// la lista de las palabras que hay en la ventana. + limpiar(&fichero); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Introduce la palabra a buscar (longitud m xima 20 letras)."); + settextstyle(2,0,5); + ventana(75,125,550,390,"Buscar una palabra (sensible al teclado)",0,0); + setcolor(0); + outtextxy(100,190,"Palabra:"); + boton(190,190,420,210,1,"",0,30); + setcolor(0); + outtextxy(100,240,"Lista:"); + boton(190,240,450,370,1,"",0,28); + icon2(85,193); + listar(dic,10);// lista las 10 primeras del diccionario. + intro_sen(200,195,cad,0,2,4);// introduce la letra sensiblemente + if (cad[0]!=27){// si no quiere irse + fichero.palabra[0]=cad[0];// la copiamos + fichero.palabra[1]=NULL; + strlwr(fichero.palabra); + boton(190,240,450,370,1,"",0,28); + listar_sen(dic,10,fichero.palabra,lista);// la listamos + intro_sen(206,195,cad,0,2,4);// introducimos la segunda + if (cad[0]!=27){// si no se va + fichero.palabra[1]=cad[0];// idem + fichero.palabra[2]=NULL; + strlwr(fichero.palabra); + boton(190,240,450,370,1,"",0,28); + listar_sen(dic,10,fichero.palabra,lista); + intro_sen(212,195,cad,0,2,4); + if (cad[0]!=27){// idem + fichero.palabra[2]=cad[0]; + fichero.palabra[3]=NULL; + strlwr(fichero.palabra); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Elige con los cursores la palabra para ver la definici¢n."); + settextstyle(2,0,5); + ventana(75,125,550,390,"Buscar una palabra (sensible al teclado)",0,0); + setcolor(0); + outtextxy(100,190,"Palabra:"); + boton(190,190,420,210,1,"",0,28); + setcolor(0); + settextstyle(2,0,5); + outtextxy(100,240,"Lista:"); + boton(190,240,450,370,1,"",0,30); + settextstyle(2,0,4); + listar_sen(dic,10,fichero.palabra,lista);// lis definitiva + icon2(85,243); + setcolor(0);settextstyle(2,0,4); + outtextxy(200,195,lista[0]); + int sw3=1, flecha=0, cual=0;// refuerzos + while (sw3){// mientras no eliga o se quiera ir + flecha=getch();// lo de siempre + if (flecha==0){ + flecha=getch(); + switch(flecha){// se va combiando el fondo azul de las palabras. + case 72: // flecha arriba. + if (cual>0){ + boton(190,240,450,370,1,"",0,30); + cual--; + for (int n=0,y=245;n<10;n++, y+=12){ + if (n==cual){ + setcolor(1); + rectangle(195,y,400,y+11); + setfillstyle(1,1); + floodfill(201,y+1,1); + setcolor(30); + outtextxy(200,y,lista[n]); + boton(190,190,420,210,1,"",0,28); + setcolor(0); + outtextxy(200,195,lista[n]); + }// fin if n=cual + else{ + setcolor(0); + outtextxy(200,y,lista[n]); + }// fin else n=cual + }// fin for + }//fin if cual>0 + break; + case 80: // flecha abajo. + if (cual<9){ + boton(190,240,450,370,1,"",0,30); + cual++; + for (int n=0,y=245;n<10;n++, y+=12){ + if (n==cual){ + setcolor(1); + rectangle(195,y,400,y+11); + setfillstyle(1,1); + floodfill(201,y+1,1); + setcolor(30); + outtextxy(200,y,lista[n]); + boton(190,190,420,210,1,"",0,28); + setcolor(0); + outtextxy(200,195,lista[n]); + } // fin if n==cual + else{ + setcolor(0); + outtextxy(200,y,lista[n]); + }// fin else n=cual + }// fin del for + }// fin if cual<10 + break; + }// fin switch flecha + }// fin if flecha 0 + else{ + if (flecha==13){// a elegido una + strcpy(fichero.palabra,lista[cual]); + buscar(dic,&fichero);// la buscamos + boton(190,240,450,370,1,"",0,28); + icon8(85,243); + settextstyle(2,0,5);setcolor(7); + outtextxy(100,240,"Lista:"); + setcolor(0); + outtextxy(100,240,"Definici¢n:"); + imprime_def(fichero.definicion);// le imprimimos la def + sw3=0;// se acab¢ + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + settextstyle(2,0,4);setcolor(0); + outtextxy(30,460,"Pulse cualquier tecla para volver al men£ de b£squeda."); + getch();// mira bien la def + } // fin if flecha 13 + else + if (flecha==27)// se quiere ir + sw3=0;// pues vete + }// fin else flecha 0 + }// fin while sw3 + }// fin de los if de control del ESC. + }// idem + }// idem +}// fin de la funci¢n buscar sen. + +void guardar_arbol(struct letra1 *dic){// guarda el  rbol. + struct letra1 *aux=NULL;//Puntero auxiliar del tipo 1, dic es el semiboss. + struct letra2 *aux2=NULL;//Puntero auxiliar del tipo 2. Y ya van 3 :-(. + struct letra3 *aux3=NULL;//Puntero auxiliar del tipo 3. Son 4 :-|. + struct def *aux4=NULL;//Punteros auxiliares del tipo 4. + FILE *fich=NULL, *f=NULL;// los ficheros + int con=0;// haber cuantas palabras hay. + if ((fich=fopen("k:\\files\\diccio.bsd","w+b"))==NULL){ + printf ("No se puede guardar el diccionario.");getch(); + } + else{ + fwrite("Fichero del diccionario",23,1,fich);// encabezado + fwrite("\n",2,1,fich); + for(aux=dic;aux!=NULL;aux=aux->sig)// grabaci¢n + for (aux2=aux->nivel2;aux2!=NULL;aux2=aux2->sig) + for (aux3=aux2->nivel3;aux3!=NULL;aux3=aux3->sig){ + if (aux3->lista!=NULL) + for (aux4=aux3->lista;aux4!=NULL;aux4=aux4->sig){ + limpiar(&fichero); + strcpy(fichero.palabra,aux4->palabra); + strcpy(fichero.definicion,aux4->definicion); + fwrite(&fichero,sizeof(struct temporal),1,fich);// grabando... + con++;// uno m s + } + } + } + fclose(fich);// cerrando + f=fopen("k:\\files\\diccio.cfg","w+b");// abrimos el otro + fwrite(&con,sizeof(int),1,f);// metemos cuantos hay + fclose(f);// se cierra +}// fin de la funci¢n guardar el diccionario. + +int huge detectEGA(void){// la resoluci¢n de la pantalla +return(2);// 640x480 +}// fin de la funci¢n de la resoluci¢n. + +void checkerrors(void){// comprueba los errores + int errorcode; + + /* read result of last graphics operation */ // no sepo ingl‚s + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Graphics error: %s\n", grapherrormsg(errorcode)); + printf("Press any key to halt:"); + getch(); + exit(1); + } +}// fin de la funci¢n de los errores de la inicializaci¢n. + +void menu(){// pinta el men£ general + settextstyle(2,0,6); + boton(180,150,430,175,0," Buscar una palabra",16,0); + boton(180,195,430,220,0," A¤adir una palabra",16,0); + boton(180,240,430,265,0," Modificar una palabra",16,0); + boton(180,285,430,310,0," Acerca de...",16,0); + boton(180,330,430,355,0," Salir",16,0); +}// fin de la funci¢n que pinta el men£ general. + +void menu_buscar(){// pinta el men£ de buscar + settextstyle(2,0,6); + boton(180,150,430,175,0," Buscar palabra",16,0); + boton(180,195,430,220,0,"Buscar palabra con lista",16,0); + boton(180,240,430,265,0," Acerca de...",16,0); + boton(180,285,430,310,0," Volver",16,0); +}// fin de la funci¢n que pinta el men£ de buscar. + +void acerca_de(){// pinta la ventana de informaci¢n de los creadores. + base(); + settextstyle(2,0,5); + ventana(125,100,525,400,"Acerca de... ;-)",0,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(30,460,"Creadores del Diccionario Interactivo DICSEN."); + settextstyle(7,1,6); + setcolor(26); + outtextxy(430,133,"PROSOFT"); + settextstyle(2,0,5); + setcolor(0); + outtextxy(150,140,"Programadores:"); + outtextxy(150,250,"Dise¤adores Gr ficos:"); + setcolor(15); + line(140,158,500,158); + line(140,268,500,268); + setcolor(8); + line(140,157,500,157); + line(140,267,500,267); + icon2(150,173); + icon2(150,283); + icon2(150,213); + icon2(150,323); + setcolor(0); + outtextxy(170,170,"Mois‚s Virumbrales Cuenca"); + outtextxy(170,320,"Mois‚s Virumbrales Cuenca"); + outtextxy(170,210,"Juan L¢pez Fern ndez"); + outtextxy(170,280,"Juan L¢pez Fern ndez"); + settextstyle(2,0,4); + outtextxy(180,190,"E-mail:"); + outtextxy(180,230,"E-mail:"); + outtextxy(180,300,"E-mail:"); + outtextxy(180,340,"E-mail:"); + setcolor(1);outtextxy(230,190,"moisesvcuenca@hotmail.com"); + outtextxy(230,340,"moisesvcuenca@hotmail.com"); + outtextxy(230,230,"juanlf@hotmail.com"); + outtextxy(230,300,"juanlf@hotmail.com"); + setcolor(0);settextstyle(2,0,3); + outtextxy(150,370,"Este programa est  realizado para PROSOFT Software. Esta prohibida la reproducci¢n total o"); + outtextxy(150,380,"parcial del programa sin la autorizaci¢n expresa de PROSOFT Software."); + settextstyle(2,0,4); + outtextxy(435,380,"Copyright 1999"); + getch();// mirala bien +}// fin de la funci¢n de la ventana de los creadores. + + +void rectangulo(int pos){// funci¢n que pinta el rectangulo de los botones. + setlinestyle(1,0,2); + switch (pos){// Ahora pintamos un recuadro al bot¢n seleccionado. + case 1: + rectangle(185,154,425,171); + setlinestyle(0,0,2);rectangle(180,150,430,175); + break; + case 2: + rectangle(185,199,425,216); + setlinestyle(0,0,2);rectangle(180,195,430,220); + break; + case 3: + rectangle(185,244,425,261); + setlinestyle(0,0,2);rectangle(180,240,430,265); + break; + case 4: + rectangle(185,289,425,306); + setlinestyle(0,0,2);rectangle(180,285,430,310); + break; + case 5: + rectangle(185,334,425,351); + setlinestyle(0,0,2);rectangle(180,330,430,355); + break; + } // fin del switch-case(pos). + setlinestyle(0,0,0); // volvemos a poner el estilo de l¡nea normal. +}// fin de la funci¢n que pinta el recuadro. + +void base(){// pinta el fondo y el t¡tulo y la barra inferior. + line (0,0,getmaxx(),getmaxy()); + setfillstyle(1,125); + bar(0,0,getmaxx(),getmaxy()); + boton(0,0,getmaxx(),50,0,"",16,124); + setcolor(0); + settextstyle(5,0,4); + outtextxy(60,0,"Diccionario Interactivo"); + settextstyle(7,0,5); + outtextxy(400,0,"DICSEN"); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); +}// fin de la funci¢n que pinta la base. + +void intro_letras(int x, int y, char cad[], int a, + int c, int s, int t, int col) {// introduce la palabra. + int i; + for (i=0;i<=a-1;) { + if (i0){ + setcolor(col);settextstyle(s,0,t);outtextxy(x,y,cad); + cad[i-1]=NULL;i-=2; + } + else{ + sound(1000);delay(50);nosound();i--; + } + } + if ((cad[i]!=13 && cad[i]!=8) && (cad[i]<65 || (cad[i]>90 && cad[i]<97) + || cad[i]>122)){ + cad[i]=NULL; + sound(1000);delay(50);nosound();i--; + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + icon10(5,455); + settextstyle(2,0,4);setcolor(4); + outtextxy(30,460,"Solo se pueden introducir letras, no se puede introducir cualquier otro car cter (ni letras acentuadas)."); + } + setcolor(c);settextstyle(s,0,t);outtextxy(x,y,cad); + } + else { + if (i==a-1 && cad[i]!=13){ + cad[i]=getche(); + if (cad[i]!=13 && cad[i]!=8){ + sound(1000);delay(50);nosound(); + } + else{ + if (cad[i]==8 && i>=0){ + setcolor(col);settextstyle(s,0,t);outtextxy(x,y,cad); + cad[i-1]=NULL;i--; + setcolor(c);settextstyle(s,0,t);outtextxy(x,y,cad); + } + } + i--; + } + } + if (cad[i]==13 && i>0) + break; + else + if (cad[i]==13 && i==0) + i--; + if (cad[0]!=NULL) + i++; + if (i==-1) + i++; + } + cad[i]=NULL; +}// fin de la funci¢n de introducir la palabra. + + +void introdef(int x, int y, char cad[], int a, + int c, int s, int t, int col) {// introduce la def. + int i, posx=x,posy=y+10;// algor¡tmo del cursor demasiado complicado. + setcolor(0);line(x,y+10,x+4,y+10);// cursor de posici¢n. Fue idea feliz. + for (i=0;i<=a-1;) { + if (i0){ + setcolor(30);line(posx,posy,posx+4,posy);// cursor de posici¢n. + setcolor(col);settextstyle(s,0,t); + char aux[2];aux[1]=NULL; + int xaux=x, yaux=y; + for (int pos=0;pos<=37 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + if (cad[pos]!=NULL){ + yaux=yaux+12;xaux=x; + for (;pos<=75 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + } + if (cad[pos]!=NULL){ + yaux=yaux+12;xaux=x; + for (;pos<=100 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + } + setcolor(0);line(xaux,yaux+10,xaux+4,yaux+10);// cursor de posici¢n. + posx=xaux;posy=yaux+10; + cad[i-1]=NULL;i-=2; + } + else{ + sound(1000);delay(50);nosound();i--; + } + } + setcolor(30);line(posx,posy,posx+4,posy);// cursor de posici¢n. + char aux[2];aux[1]=NULL; + int xaux=x, yaux=y; + setcolor(c);settextstyle(s,0,t); + for (int pos=0;pos<=37 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + if (cad[pos]!=NULL){ + yaux=yaux+12;xaux=x; + for (;pos<=75 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + } + if (cad[pos]!=NULL){ + yaux=yaux+12;xaux=x; + for (;pos<=100 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + } + setcolor(0);line(xaux,yaux+10,xaux+4,yaux+10);// cursor de posici¢n. + posx=xaux;posy=yaux+10; + } + else { + if (i==a-1 && cad[i]!=13){ + cad[i]=getche(); + if (cad[i]!=13 && cad[i]!=8){ + sound(1000);delay(50);nosound(); + } + else{ + if (cad[i]==8 && i>=0){ + char aux[2];aux[1]=NULL; + int xaux=x, yaux=y; + setcolor(col);settextstyle(s,0,t); + for (int pos=0;pos<=37 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + if (cad[pos]!=NULL){ + yaux=yaux+12;xaux=x; + for (;pos<=75 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + } + if (cad[pos]!=NULL){ + yaux=yaux+12;xaux=x; + for (;pos<=100 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + } + cad[i-1]=NULL;i--; + setcolor(30);line(posx,posy,posx+4,posy);// cursor de posici¢n. + setcolor(c);settextstyle(s,0,t); + for (pos=0;pos<=37 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + if (cad[pos]!=NULL){ + yaux=yaux+12;xaux=x; + for (;pos<=75 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + } + if (cad[pos]!=NULL){ + yaux=yaux+12;xaux=x; + for (;pos<=100 && cad[pos]!=NULL;pos++,xaux+=6){ + aux[0]=cad[pos]; + outtextxy(xaux,yaux,aux); + } + } + setcolor(0);line(xaux,yaux+10,xaux+4,yaux+10);// cursor de posici¢n. + posx=xaux;posy=yaux+10; + } + } + i--; + } + } + if (cad[i]==13 && i>0) + break; + else + if (cad[i]==13 && i==0) + i--; + if (cad[0]!=NULL) + i++; + if (i==-1) + i++; + } + cad[i]=NULL; +}// fin de la funci¢n de introducir la definici¢n. + +void intro_sen(int x, int y, char cad[], int c, int s, int t){// intro las 3 1¦ + int i=0, sw=1; + while (sw){ + cad[i]=getch(); + if(cad[i]!=27 && (cad[i]<65 || (cad[i]>90 && cad[i]<97) || cad[i]>122)){ + cad[i]=NULL; + sound(1000);delay(50);nosound(); + boton(0,450,getmaxx(),getmaxy(),0,"",0,0); + icon10(5,455); + settextstyle(2,0,4);setcolor(4); + outtextxy(30,460,"Solo se pueden introducir letras, no se puede introducir cualquier otro car cter (ni letras acentuadas)."); + } + else { + setcolor(c);settextstyle(s,0,t);outtextxy(x,y,cad);sw=0; + } + } + cad[i+1]=NULL; +}// fin de la funci¢n de introducci¢n de las tres 1¦ + + +/*void borrar_arbol(struct letra1 *dic){ // Pinta el  rbol. + for(struct letra1 *n1=dic;n1!=NULL;n1=n1->sig){ + for (struct letra2 *n2=n1->nivel2;n2!=NULL;n2=n2->sig){ + for (struct letra3 *n3=n2->nivel3;n3!=NULL;n3=n3->sig){ + if (n3->lista!=NULL) + for (struct def *n4=n3->lista;n4!=NULL;n4=n4->sig){ + + } + } + } + } +}*/ \ No newline at end of file diff --git a/CPP/DICCIO.EXE b/CPP/DICCIO.EXE new file mode 100644 index 0000000..8b7f1a0 Binary files /dev/null and b/CPP/DICCIO.EXE differ diff --git a/CPP/DXVIDEO.CPP b/CPP/DXVIDEO.CPP new file mode 100644 index 0000000..0cff674 --- /dev/null +++ b/CPP/DXVIDEO.CPP @@ -0,0 +1,119 @@ +// ************************************************************************************************ +// +// Direct Video +// +// +// ************************************** (c) Pedro Díez López ************************************ + +#include +#include "DXVideo.h" +// +// Inicio +// +BOOL CDXVideo::Inicio(HWND hwnd,int Ancho,int Alto,int BPP) +{ + char buf[256]; + + ddrval = DirectDrawCreate(NULL, &lpDD, NULL); + + if(ddrval == DD_OK) + { + ddrval = lpDD->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + if(ddrval == DD_OK) + { + ddrval = lpDD->SetDisplayMode(Ancho,Alto,BPP); + if(ddrval == DD_OK) + { + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; + ddsd.dwBackBufferCount = 1; + ddrval = lpDD->CreateSurface(&ddsd, &lpDDSView, NULL); + if(ddrval == DD_OK) + { + ddscaps.dwCaps = DDSCAPS_BACKBUFFER; + ddrval = lpDDSView->GetAttachedSurface(&ddscaps, &lpDDSBack); + if(ddrval == DD_OK) + { + hres = Ancho; + vres = Alto; + bpp = BPP; + ElmBuffer = hres*vres; + DimBuffer = hres*vres*(bpp/8); + pBuffer.bpp = malloc (DimBuffer); + if(pBuffer.bpp==NULL) + { + hres = 0; + vres = 0; + bpp = 0; + ElmBuffer = 0; + DimBuffer = 0; + Fin(); + return FALSE; + } + return TRUE; + } + } + } + } + } + wsprintf(buf, "Fallo %08lX al iniciliazr DirectDraw\n",ddrval); + MessageBox(hwnd, buf, "ERROR DirectX", MB_OK); + Fin(); + return FALSE; +} + +// +// Cursor +// +void CDXVideo::Cursor(HCURSOR nCursor) +{ + mDDCursorShape = nCursor; +} + +// +// Pinta +// +void CDXVideo::Pinta () +{ + // Copia el buffer de trabajo al BackBuffer. + while (TRUE) + { + ddrval=lpDDSBack->Lock(NULL,&ddsd,0,NULL); + if(ddrval == DD_OK) break; + if (ddrval != DDERR_WASSTILLDRAWING) return; + } + lpDXBuffer = (void *)ddsd.lpSurface; + memcpy(lpDXBuffer,pBuffer.bpp,DimBuffer); + lpDDSBack->Unlock(NULL); + // Cambia el buffer. + while (TRUE) + { + ddrval=lpDDSView->Flip(NULL, 0); + if (ddrval == DD_OK) return; + if (ddrval == DDERR_SURFACELOST) + { + ddrval=lpDDSView->Restore(); + if (ddrval!=DD_OK) return; + } + if (ddrval!=DDERR_WASSTILLDRAWING) return; + } +} + +// +// Fin +// +void CDXVideo::Fin() +{ + if (pBuffer.bpp != NULL) free (pBuffer.bpp); + if(lpDD != NULL) + { + if(lpDDSView!=NULL) + { + lpDDSView->Release(); + lpDDSView = NULL; + } + lpDD->Release(); + lpDD = NULL; + } +} diff --git a/CPP/EJEMPLO1.CPP b/CPP/EJEMPLO1.CPP new file mode 100644 index 0000000..f6b1336 --- /dev/null +++ b/CPP/EJEMPLO1.CPP @@ -0,0 +1,31 @@ +// Programa ejemplo 1 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Program ejemplo de tablas. + + +#include +#include + +int tabla[10]; +int con; + +void main() { + for (con=0;con<10;con++) { + clrscr(); + gotoxy (20,12); + printf ("Introduce n£meros para llenar la tabla: "); + fflush (stdin); + scanf ("%5d",&tabla[con]); + } + clrscr(); + for (con=0;con<10;con++) + printf ("\nEl valor introducido en la posici¢n %d es: %d",con+1,tabla[con]); + fflush(stdin); + getch(); +} \ No newline at end of file diff --git a/CPP/EJEMPLO2.CPP b/CPP/EJEMPLO2.CPP new file mode 100644 index 0000000..2f11acb --- /dev/null +++ b/CPP/EJEMPLO2.CPP @@ -0,0 +1,32 @@ +// Programa ejemplo 2 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Program ejemplo de tablas. + + +#include +#include + +int tabla[100]; +int con,num,conaux; + +void main() { + for (con=0,num=10;con<100;con++,num=num+2) + tabla[con]=num; + clrscr(); + for (con=99;con>=0;con--,conaux++) { + printf ("\nEl valor introducido en la posici¢n %d es: %d",con+1,tabla[con]); + if (conaux==24) { + fflush (stdin); + getch(); + conaux=0; + } + } + fflush (stdin); + getch(); +} \ No newline at end of file diff --git a/CPP/EJEMPLO3.CPP b/CPP/EJEMPLO3.CPP new file mode 100644 index 0000000..54eb0ca --- /dev/null +++ b/CPP/EJEMPLO3.CPP @@ -0,0 +1,17 @@ +// ejemplo3 + +#include +#include + +int matriz [5][4]; +int f,c,cont=1; + +void main() { + clrscr(); + for(f=0;f<5;f++) + for (c=0;c<4;c++,cont++) { + matriz[f][c]=cont; + printf ("\nMatriz [%d][%d] contiene %d y su direcci¢n es: %p",f,c,matriz[f][c],&matriz[f][c]); + } +getch(); +} \ No newline at end of file diff --git a/CPP/EJEMPLO4.CPP b/CPP/EJEMPLO4.CPP new file mode 100644 index 0000000..34d6b61 --- /dev/null +++ b/CPP/EJEMPLO4.CPP @@ -0,0 +1,27 @@ +// ejemplo4 + +#include +#include + +int tabla[10][10],num,x,y,sw=1; +void main(){ + clrscr(); + for (y=0,num=1;y<10;y++){ + if (sw==1) + for (x=0;x<10;x++,num++){ + tabla[y][x]=num; + printf ("\nValor de la posici¢n [%d][%d] es: %d",y,x,tabla[y][x]); + sw=0; + } + else + for (x=9;x>=0;x--,num++){ + tabla[y][x]=num; + printf ("\nValor de la posici¢n [%d][%d] es: %d",y,x,tabla[y][x]); + sw=1; + } + fflush(stdin); + getch(); + } + fflush(stdin); + getch(); +} diff --git a/CPP/ESTADO.CPP b/CPP/ESTADO.CPP new file mode 100644 index 0000000..a64547b --- /dev/null +++ b/CPP/ESTADO.CPP @@ -0,0 +1,35 @@ +#include +#include +#include + +void main(){ + clrscr(); + for (int j=0;j<=40;j++){ + textcolor(7);gotoxy(3+j,5);cprintf("Û"); + } + textbackground(7);textcolor(15);gotoxy(3,5);cprintf("0%"); + for (j=0;j<=40;j++){ + textcolor(16); + if (((j*2)+25)<=100){ + if (j>6){ + gotoxy((j-1)/2,5);textcolor(4); + cprintf("Û"); + gotoxy(j/2,5); + } + else + gotoxy(3,5); + textcolor(15);textbackground(4); + cprintf("%d%",(j*2)+25); + } + textcolor(4); + if (j==18) + textbackground(4); + if (j<=40){ + gotoxy(3+j,5);cprintf("Û"); + } + delay(50); + + } + textcolor(7);textbackground(0); + getch(); +} \ No newline at end of file diff --git a/CPP/MENU.CPP b/CPP/MENU.CPP new file mode 100644 index 0000000..91bb11f --- /dev/null +++ b/CPP/MENU.CPP @@ -0,0 +1,148 @@ +/* ESTE PROGRAMA GENERA UN MENU DE 3 OPCIONES, DONDE LAS OPCIONES SON +SELECCIONADAS POR LOS CURSORES Y LA TECLA ENTER*/ + +#include +#include +#include +/* PROTOTIPOS DE LAS FUNCIONES UTILIZADAS */ +void impri(int,char[],int,int);/*IMPRIME LAS OPCIONES DEL MENU int,COLOR DE + IMPRESION, cha[],CADENA A IMPRIMIR, + int, COLUMNA, int, FILA*/ +void cursor(char[3][10],int,int,int);/* MANEHO DE LOS CURSORES Y SELECION DE + OPCION, char[3][10],MATRIZ DE CADENAS + int,COLUMNA, int,FILA int,INDICE PARA + LA MATRIZ*/ +void main() +{ +_setcursortype(_NOCURSOR);/*FUNCION QUE NOS PERMITE OCULTAR EL CURSOR EN + PANTALLA SUS POSIBLES VALORES SON: + _NOCURSOR: EL CURSOR NO APARECE VALOR 0 + _SOLIDCURSOR: EL CURSOR APARECE GRUESO VALOR 1 + _NORMALCURSOR: NORMAL CURSOR VALOR 2 + _setcursortype(int) se encuentra en conio.h + en dicha libreria estan definidas las + constantes _NOCURSOR,_SOLIDCURSOR Y _NORMALCURSOR*/ +int sw=0,color,c,f,col,fil, indice; +char cad[3][10]={"PRIMERA","SEGUNDA","SALIR"};/* MATRIZ DE CADENAS, CON LAS + OPCIONES DEL MENU*/ +clrscr(); +color=7; +impri(color,cad[0],30,10); +impri(color,cad[1],30,12); +impri(color,cad[2],30,14); +col=30; +fil=10; +indice=0; +while(sw==0) +{ + cursor(cad,col,fil,indice); + if(wherey()==10) + { col=30; + fil=10; + gotoxy(20,24); + textcolor(142); + cprintf("OPCION PRIMERA"); + textcolor(14); + cprintf("\t PULSE UNA TECLA PARA VOLVER AL MENU"); + textcolor(7); + getch(); + gotoxy(20,24); + printf(" "); + indice=0; + } + else + if(wherey()==12) + { + col=30; + fil=12; + gotoxy(20,24); + textcolor(142); + cprintf("OPCION SEGUNDA"); + textcolor(14); + cprintf("\t PULSE UNA TECLA PARA VOLVER AL MENU"); + textcolor(7); + gotoxy(20,24); + getch(); + printf(" "); + indice=1; + } + else + { + col=30; + fil=14; + gotoxy(20,24); + textcolor(142); + printf("SALIR"); + textcolor(14); + cprintf("\t PULSE UNA TECLA PARA VOLVER AL MENU"); + textcolor(7); + sw=1; + getch(); + gotoxy(20,24); + printf(" "); + indice=2; + } +} +_setcursortype(_NORMALCURSOR); +} + +//DESARROLLO DE LAS FUNCIONES +void impri(int color, char cad[],int c,int f) +{ + textcolor(color); + gotoxy(c,f); + cprintf("OPCION %s",cad); +} +void cursor(char cad[3][10],int c,int f,int indice) +{ +int sw=0,i,a; + gotoxy(c,f); + impri(14,cad[indice],c,f); + while(sw==0) + { + + i=getche(); + if(i==0) + { + a=getch(); + switch(a) + { + case 72: + { + gotoxy(c,f); + impri(7,cad[indice],c,f); + if(f==10) + f=14; + else + f=f-2; + gotoxy(c,f); + if(indice==0) + indice=2; + else + indice--; + impri(14,cad[indice],c,f); + break; + } + case 80: + { + gotoxy(c,f); + impri(7,cad[indice],c,f); + if(f==14) + f=10; + else + f=f+2; + gotoxy(c,f); + if(indice==2) + indice=0; + else + indice++; + impri(14,cad[indice],c,f); + break; + } + } + } + else + if(i==13) + sw=1; + } + } \ No newline at end of file diff --git a/CPP/MENU.~CP b/CPP/MENU.~CP new file mode 100644 index 0000000..2fee352 --- /dev/null +++ b/CPP/MENU.~CP @@ -0,0 +1,149 @@ +/* ESTE PROGRAMA GENERA UN MENU DE 3 OPCIONES, DONDE LAS OPCIONES SON +SELECCIONADAS POR LOS CURSORES Y LA TECLA ENTER*/ + +#include +#include +#include +/* PROTOTIPOS DE LAS FUNCIONES UTILIZADAS */ +void impri(int,char[],int,int);/*IMPRIME LAS OPCIONES DEL MENU int,COLOR DE + IMPRESION, cha[],CADENA A IMPRIMIR, + int, COLUMNA, int, FILA*/ +void cursor(char[3][10],int,int,int);/* MANEHO DE LOS CURSORES Y SELECION DE + OPCION, char[3][10],MATRIZ DE CADENAS + int,COLUMNA, int,FILA int,INDICE PARA + LA MATRIZ*/ +void main() +{ +_setcursortype(_NOCURSOR);/*FUNCION QUE NOS PERMITE OCULTAR EL CURSOR EN + PANTALLA SUS POSIBLES VALORES SON: + _NOCURSOR: EL CURSOR NO APARECE VALOR 0 + _SOLIDCURSOR: EL CURSOR APARECE GRUESO VALOR 1 + _NORMALCURSOR: NORMAL CURSOR VALOR 2 + _setcursortype(int) se encuentra en conio.h + en dicha libreria estan definidas las + constantes _NOCURSOR,_SOLIDCURSOR Y _NORMALCURSOR*/ +int sw=0,color,c,f,col,fil, indice; +char cad[3][10]={"PRIMERA","SEGUNDA","SALIR"};/* MATRIZ DE CADENAS, CON LAS + OPCIONES DEL MENU*/ +clrscr(); +color=7; +impri(color,cad[0],30,10); +impri(color,cad[1],30,12); +impri(color,cad[2],30,14); +col=30; +fil=10; +indice=0; +while(sw==0) +{ + cursor(cad,col,fil,indice); + if(wherey()==10) + { col=30; + fil=10; + gotoxy(20,24); + textcolor(142); + cprintf("OPCION PRIMERA"); + textcolor(14); + cprintf("\t PULSE UNA TECLA PARA VOLVER AL MENU"); + textcolor(7); + getch(); + gotoxy(20,24); + printf(" +"); + indice=0; + } + else + if(wherey()==12) + { + col=30; + fil=12; + gotoxy(20,24); + textcolor(142); + cprintf("OPCION SEGUNDA"); + textcolor(14); + cprintf("\t PULSE UNA TECLA PARA VOLVER AL MENU"); + textcolor(7); + gotoxy(20,24); + getch(); + printf(" "); + indice=1; + } + else + { + col=30; + fil=14; + gotoxy(20,24); + textcolor(142); + printf("SALIR"); + textcolor(14); + cprintf("\t PULSE UNA TECLA PARA VOLVER AL MENU"); + textcolor(7); + sw=1; + getch(); + gotoxy(20,24); + printf(" "); + indice=2; + } +} +_setcursortype(_NORMALCURSOR); +} + +//DESARROLLO DE LAS FUNCIONES +void impri(int color, char cad[],int c,int f) +{ + textcolor(color); + gotoxy(c,f); + cprintf("OPCION %s",cad); +} +void cursor(char cad[3][10],int c,int f,int indice) +{ +int sw=0,i,a; + gotoxy(c,f); + impri(14,cad[indice],c,f); + while(sw==0) + { + + i=getche(); + if(i==0) + { + a=getch(); + switch(a) + { + case 72: + { + gotoxy(c,f); + impri(7,cad[indice],c,f); + if(f==10) + f=14; + else + f=f-2; + gotoxy(c,f); + if(indice==0) + indice=2; + else + indice--; + impri(14,cad[indice],c,f); + break; + } + case 80: + { + gotoxy(c,f); + impri(7,cad[indice],c,f); + if(f==14) + f=10; + else + f=f+2; + gotoxy(c,f); + if(indice==2) + indice=0; + else + indice++; + impri(14,cad[indice],c,f); + break; + } + } + } + else + if(i==13) + sw=1; + } + } diff --git a/CPP/MIMENU.CPP b/CPP/MIMENU.CPP new file mode 100644 index 0000000..57daa15 --- /dev/null +++ b/CPP/MIMENU.CPP @@ -0,0 +1,219 @@ +#include +#include +#include +#include +#include + +#define seleccionado color_numero=color_menu=9;settextstyle(7,0,4); +#define no_seleccionado color_numero=3;color_menu=8;settextstyle(8,0,3); + +int select_actual=1,num_opciones=5,estoy_en=0; + +void menu_principal(int selec_actual); // INICIALIZACION DE FUNCIONES +void sub_menu(int menu); +void modo_grafico(); +void leer_tecla(int num_opciones); +void satelite_gsm(int senyal); + +// PROGRAMA PRINCIPAL +//------------------- +void main() { + modo_grafico(); + + menu_principal(select_actual); + leer_tecla(num_opciones); + + getch(); + closegraph(); + +} + + +//FUNCIàN QUE INICIA EL MODO GRµFICO +//---------------------------------- +void modo_grafico(){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "d:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", grapherrormsg(errorcode)); + printf("Pulse cualquier tecla para finalizar..."); + getch(); + exit(1); + } +} + + +// FUNCIàN QUE LEE LAS TECLAS PULSADAS +//------------------------------------ +void leer_tecla(int num_opciones) { + int tecla,tecla2,sw=1,pintar=0; // VARIABLES + + while(sw==1){ + + tecla=getch(); + + if(tecla==0){ + tecla2=getch(); + pintar=0; + switch(tecla2){ + case 72: + if (select_actual<=1) + select_actual=num_opciones; + else + select_actual--; + pintar=1; + break; + case 80: + if (select_actual>=num_opciones) + select_actual=1; + else + select_actual++; + pintar=1; + break; + } + } + else + if (tecla==13){ + pintar=0; + clearviewport(); + satelite_gsm(select_actual); + + } + else + if (tecla==27) + sw=0; + + if (pintar) { + clearviewport(); + // satelite_gsm(select_actual); + menu_principal(select_actual); + } + } +} +// FUNCIàN QUE NOS DICE EN QUE LUGAR DEL MENU NOS ENCONTRAMOS +//----------------------------------------------------------- +void satelite_gsm(int senyal) { +if (estoy_en==0){ + estoy_en=senyal; + sub_menu(senyal); +} +} + +void sub_menu(int menu){ + int color_numero=9,color_menu=2,pos_number=0,pos_menu=pos_number+50; + setviewport(170, 100, 600, 300, 0); + switch (menu) { + case 1: // MENU 1: CLIENTES + estoy_en=1; + if (select_actual==1){seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,0,"1.-"); + setcolor(color_menu);outtextxy(pos_menu,0,"Altas de Clientes"); + if (select_actual==2) {seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,40,"2.-"); + setcolor(color_menu);outtextxy(pos_menu,40,"Bajas de Clientes"); + if (select_actual==3){seleccionado;} + else{no_seleccionado} + setcolor(color_menu);outtextxy(pos_menu,80,"Modificaciones"); + setcolor(color_numero);outtextxy(0,80,"3.-"); + if (select_actual==4){seleccionado} + else{no_seleccionado} + setcolor(color_menu);outtextxy(pos_menu,120,"Listar Clientes"); + setcolor(color_numero);outtextxy(0,120,"4.-"); + if (select_actual==5){seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,160,"5.-"); + setcolor(color_menu);outtextxy(pos_menu,160,"Volver"); + + break; + case 2: // MENU 2 GESTION DE PEDIDOS + if (select_actual==1){seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,0,"1.-"); + setcolor(color_menu);outtextxy(pos_menu,0,"Altas de Pel¡culas"); + if (select_actual==2) {seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,40,"2.-"); + setcolor(color_menu);outtextxy(pos_menu,40,"Bajas de Pel¡culas"); + if (select_actual==3){seleccionado;} + else{no_seleccionado} + setcolor(color_menu);outtextxy(pos_menu,80,"Modificaciones"); + setcolor(color_numero);outtextxy(0,80,"3.-"); + if (select_actual==4){seleccionado} + else{no_seleccionado} + setcolor(color_menu);outtextxy(pos_menu,120,"Listar Pel¡culas"); + setcolor(color_numero);outtextxy(0,120,"4.-"); + if (select_actual==5){seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,160,"5.-"); + setcolor(color_menu);outtextxy(pos_menu,160,"Volver"); + break; + case 3: // MENU 3: ALQUILERES + if (select_actual==1){seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,0,"1.-"); + setcolor(color_menu);outtextxy(pos_menu,0,"Alquiler"); + if (select_actual==2) {seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,40,"2.-"); + setcolor(color_menu);outtextxy(pos_menu,40,"Devoluci¢n"); + if (select_actual==3){seleccionado;} + else{no_seleccionado} + setcolor(color_menu);outtextxy(pos_menu,80,"Volver"); + setcolor(color_numero);outtextxy(0,80,"3.-"); + break; + case 4: + if (select_actual==1){seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,0,"1.-"); + setcolor(color_menu);outtextxy(pos_menu,0,"Alquiler"); + if (select_actual==2) {seleccionado} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,40,"2.-"); + setcolor(color_menu);outtextxy(pos_menu,40,"Devoluci¢n"); + if (select_actual==3){seleccionado;} + else{no_seleccionado} + setcolor(color_numero);outtextxy(0,80,"3.-"); + setcolor(color_menu);outtextxy(pos_menu,80,"Volver"); + break; + + } +} +// FUNCIàN QUE MUESTRA EL MENé PRINCIPAL +//-------------------------------------- +void menu_principal(int select_actual) { + setviewport(170, 100, 600, 300, 0); + int color_numero=9,color_menu=2,pos_number=0,pos_menu=pos_number+50; + + if (select_actual==1){seleccionado} + else{no_seleccionado} + + setcolor(color_numero);outtextxy(0,0,"1.-"); + setcolor(color_menu);outtextxy(pos_menu,0,"Gesti¢n de Clientes"); + + if (select_actual==2) {seleccionado} + else{no_seleccionado} + + setcolor(color_numero);outtextxy(0,40,"2.-"); + setcolor(color_menu);outtextxy(pos_menu,40,"Gesti¢n de Pedidos"); + + if (select_actual==3){seleccionado;} + else{no_seleccionado} + + setcolor(color_menu);outtextxy(pos_menu,80,"Alquileres"); + setcolor(color_numero);outtextxy(0,80,"3.-"); + + if (select_actual==4){seleccionado} + else{no_seleccionado} + + setcolor(color_menu);outtextxy(pos_menu,120,"Devoluciones"); + setcolor(color_numero);outtextxy(0,120,"4.-"); + + if (select_actual==5){seleccionado} + else{no_seleccionado} + + setcolor(color_numero);outtextxy(0,160,"5.-"); + setcolor(color_menu);outtextxy(pos_menu,160,"Salir"); +} diff --git a/CPP/ORDENA.CPP b/CPP/ORDENA.CPP new file mode 100644 index 0000000..ea1d9bd --- /dev/null +++ b/CPP/ORDENA.CPP @@ -0,0 +1,130 @@ +#include +#include +#include +#include + +FILE *maes, *mov, *movtmp; + +struct nodo { + int n; + struct nodo *sig; +}; +struct clientes{ + char nombre[11], apellidos[21], direccion[21], telefono[11]; + int codigo; +}; +struct maestro { + int codigo; + char nombre[11], apellidos[21]; + char direccion[21], telefono[11]; +}regmaes; +struct movi { + char tipo; + int codigo; + char nombre[10], apellidos[20]; + char direccion[20], telefono[10]; +}regmov; + + +void INSERTAR (struct nodo **, int); +void ORDENAR (struct nodo **); +void LISTAR_INV (struct nodo *); +void LISTAR (struct nodo *); + +int elementos=0; + struct nodo *p=NULL; +void main(void){ + + + if ((mov=fopen("k:\\files\\clientes.mov","r+b"))==NULL) + { + printf("Error. No existe el fichero de movimientos"); + exit (1); + } + else { + fread(®mov,sizeof(regmov),1,mov); + while (!feof(mov)) + { + INSERTAR(&p,regmov.codigo); + fread(®mov,sizeof(regmov),1,mov); + + } + fclose (mov); + ORDENAR(&p); + system ("rename k:\\files\\clientes.mov clientes.ord"); + + if ((movtmp=fopen("k:\\files\\clientes.ord","r+b"))==NULL) + { + printf("Error Muy Gordo. No existe el fichero temporal."); + exit (1); + } + mov=fopen("k:\\files\\clientes.mov","w+b"); + struct nodo *q=p; + while (q) { + fread(®mov,sizeof(regmov),1,movtmp); + if (regmov.codigo == q->n){ + fwrite(®mov,sizeof(regmov),1,mov); + fseek(movtmp,0,0); + q=q->sig; + } + } + //fclose(movtmp); + + LISTAR(p); + getch(); + free(p); + fcloseall(); + unlink ("k:\\files\\clientes.ord"); + } +} + + + +//****************************************************************** + + +void INSERTAR (struct nodo **p, int d){ + struct nodo *aux; + aux = (struct nodo*) malloc (sizeof(struct nodo)); + aux -> n = d; + aux -> sig = (*p); + (*p) = aux; + elementos+=1; +} + + +void ORDENAR (struct nodo **q){ + int j=0,sw=0,n=0; + struct nodo *aux1=NULL, *aux2=NULL,aux; + int i=1;sw=1; + n=elementos-1; + while (i<=n && sw==1){ + sw=0;aux2 = *q; aux1 = aux2->sig; + aux.sig=NULL; + aux.n=0; + for (j=1; j< elementos;j++) { + if ((aux2->n)>(aux1->n)){ + aux.n=aux2->n; + aux2->n=aux1->n; + aux1->n=aux.n; + sw=1; + } + aux2 = aux1; aux1 = aux1 -> sig; + } + i++; + } +} + +void LISTAR_INV (struct nodo *p){ + if (p!=NULL) { + LISTAR_INV (p->sig); + printf(" %d ",p->n); + } +} +void LISTAR (struct nodo *p){ + if (p!=NULL) { + printf(" %d ",p->n); + LISTAR (p->sig); + + } +} \ No newline at end of file diff --git a/CPP/PROG1.CPP b/CPP/PROG1.CPP new file mode 100644 index 0000000..8ee343c --- /dev/null +++ b/CPP/PROG1.CPP @@ -0,0 +1,150 @@ +// Minicalculator© Ver 3.0 +// Copyright 1998 +// +// Descripci¢n del programa: +// Este programa pide dos n£meros, luego muestra un men£ y dependiendo +// de la opci¢n elegida los suma, resta, multiplica o divide imprimiendo +// el resultado de la operaci¢n. +// +// Programadores: +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// Grupo 1§A +// +// Novedades de la Versi¢n 3.0 +// No finaliza el programa hasta que el usuario lo requiere y adem s +// se ha habilitado una nueva opci¢n para poder introducir valores nuevos. +// +// Novedades de versiones anteriores: +// Versi¢n 2.2 +// Presenta un mensaje de error si la opci¢n no est  en el men£ +// o si la divisi¢n es por cero. Adem s cuando la divisi¢n no es exacta +// se imprime el resto. Tambi‚n se ha mejorado la interface con el usuario. +// No realiza la resta ni la divisi¢n si el primer n£mero es menor que el +// segundo. +// Creado: 3-11-1998 +// éltima modificaci¢n: 12-11-1998 + +#include +#include + +int a,b,c; +char pausa; +void main () +{ + clrscr(); + printf ("\n\t\t\t Minicalculator© Ver 3.0"); + printf ("\n\t\t\t ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"); + printf ("\n\n\n\n\t\t Introduce primer n£mero: "); + fflush (stdin); + scanf ("%d",&a); + printf ("\n\n\t\t Introduce segundo n£mero: "); + fflush (stdin); + scanf ("%d",&b); + + while (c!=6) + { + clrscr(); + printf ("\n\t\t\t Minicalculator© Ver 3.0"); + printf ("\n\t\t\t ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"); + printf ("\n\n\n\t\t\t Men£ de opciones"); + printf ("\n\n\t\t 1.- Sumar los n£meros introducidos."); + printf ("\n\t\t 2.- Restar los n£meros introducidos."); + printf ("\n\t\t 3.- Multiplicar los n£meros introducidos."); + printf ("\n\t\t 4.- Dividir los n£meros introducidos."); + printf ("\n\t\t 5.- Introducir datos nuevos."); + printf ("\n\t\t 6.- Salir."); + printf ("\n\n\t\t Opci¢n deseada: "); + fflush(stdin); + scanf ("%d",&c); + + if (c==1) + { + printf ("\n\t\t La suma de los n£meros (%d+%d) es: %d",a,b,a+b); + } + else + { + if (c==2) + { + if (a +#include + +int numero,base,cociente,j_resto,numeroaux,resto,baseini; +int tabla[15]; +char aux; +// Inicializaci¢n de funciones. +void imprimir_num(int j_resto); +//int comprobar_base(baseini); + +void main () { + clrscr(); + gotoxy (20,11); + printf ("Introduce la base del n£mero: "); + fflush(stdin); + scanf ("%d",&baseini); + gotoxy (20,12); + printf ("Introduce n£mero: "); + for (j_resto=0;j_resto<15;j_resto++) { + fflush(stdin); + cscanf ("%1c",&aux); + if (aux=='t') + j_resto=15; + tabla[j_resto]=aux; + // else + // if (tabla[j_resto]==97) + + } + gotoxy (20,13); + printf ("Introduce base: "); + fflush(stdin); + scanf ("%d",&base); + numeroaux=numero; + j_resto=0; + do { + cociente=numeroaux/base; + resto=numeroaux%base; + tabla[j_resto]=resto; + j_resto++; + numeroaux=cociente; + } + while (base<=cociente); + + tabla[j_resto]=cociente; + imprimir_num(j_resto); + fflush(stdin); + getch(); +} + +// Funci¢n imprimir n£mero resultante. +void imprimir_num(int j_resto) { + clrscr(); + gotoxy(10,12); + printf ("El n£mero %d en base %d es: ",numero,base); + for (;j_resto>=0;j_resto--) { + if (tabla[j_resto]<=9) + printf ("%d",tabla[j_resto]); + else + if (tabla[j_resto]==10) + printf ("A"); + else + if (tabla[j_resto]==11) + printf ("B"); + else + if (tabla[j_resto]==12) + printf ("C"); + else + if (tabla[j_resto]==13) + printf ("D"); + else + if (tabla[j_resto]==14) + printf ("E"); + else + if (tabla[j_resto]==15) + printf ("F"); + + } +} + +// Funci¢n comprobar base. +//int comprobar_base(int baseini) { +// if (baseini<=9) +// if (tabla[j_resto]>=baseini) + // error=1; + // else + // if (tabla[j_resto]!=065 || tabla[j_resto]!=097 || tabla[j_resto]!=066 + //|| tabla[j_resto]!= 067 || tabla[j_resto]!=068 || tabla[j_resto]!=069) + + +//} \ No newline at end of file diff --git a/CPP/PROG11.CPP b/CPP/PROG11.CPP new file mode 100644 index 0000000..8775c15 --- /dev/null +++ b/CPP/PROG11.CPP @@ -0,0 +1,552 @@ +// Prog9 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// + +#include +#include + +char ventana (int ancho,int largo,int color_g,int color_borde,char titulo[], +int color_titulo,int posx,int posy); +int intentos(int nivel,int niv,int n); +char psoga();char pcabeza();char pcaraa(); char pcarat();char pcuerpo(); +char pextremidades(int lado);char dibujar(int niv,int fallo); + +void main() { + int numero[9],n=0,nivel=0,num,tabla[9],color_num[10],niv=0,soga[5][5]; + int cabeza[7][7],fallo=0; + for (int aux=0;aux<9;aux++) + tabla[aux]=10; + for (int auxi=0;auxi<=9;auxi++) + color_num[auxi]=0; + textbackground(0); + clrscr(); + ventana(80,24,7,1,"Juego del Ahorcado",14,1,1); + textcolor(6); + gotoxy(6,22); + ventana(45,7,7,8,"H",1,20,10); + ventana(45,7,7,1,"Valores iniciales del juego",14,18,9); + textcolor(0); + textbackground(7); + gotoxy(21,11); + cprintf ("Introduce nivel de dificultad(1-7): "); + textcolor(0); + fflush(stdin); + cscanf("%1d",&nivel); + gotoxy(21,13); + cprintf ("Introducir n£mero a adivinar: "); + do { + textcolor(0); + textbackground(0); + gotoxy(51,13); + fflush(stdin); + cscanf ("%1d",&numero[n]); + n++; + gotoxy (51,13); + textcolor(0); + textbackground(7); + cprintf ("_"); + } while (n=0;c--) { + if (piernad[f][c]=='Û') { + textcolor(9); + cprintf ("%c",piernad[f][c]); + } + else { + textcolor(7); + cprintf ("Û"); + } + } + } + } + if (lado==4) { + // Brazo Derecho + for (int f=0,y=12;f<4;f++,y++) { + gotoxy(69,y); + for (int c=0;c<9;c++) { + if (piernad[f][c]=='Û') { + textcolor(9); + cprintf ("%c",piernad[f][c]); + } + else { + textcolor(7); + cprintf ("Û"); + } + } + } + } + if (lado==3) { + // Izquierda. + for (int f=0,y=12;f<4;f++,y++) { + gotoxy(49,y); + for (int c=8;c>=0;c--) { + if (piernad[f][c]=='Û') { + textcolor(9); + cprintf ("%c",piernad[f][c]); + } + else { + textcolor(7); + cprintf ("Û"); + } + } + } + } + return(0); +} \ No newline at end of file diff --git a/CPP/PROG13.CPP b/CPP/PROG13.CPP new file mode 100644 index 0000000..f881538 --- /dev/null +++ b/CPP/PROG13.CPP @@ -0,0 +1,422 @@ +#include +#include + +char ventana (int ancho,int largo,int color_g,int color_borde,char titulo[], +int color_titulo,int posx,int posy); +char ventanaarchivo(int op);char ventanaoperaciones(); +char ventanaayuda(int op);char ventanageneral(int op); +char ventanatipomatriz(); +char pagina(int numero);char instrucciones(char opt,int numero_pag); +void main(){ + int salir=0; + do { + char tecla; + int numero=0,col,tipomatriz; + ventanageneral(0); + do { + textcolor(1);textbackground(1);gotoxy(78,24); + fflush(stdin);cscanf("%1c",&tecla);numero=tecla; + } while (numero!=97 && numero!=121 && numero!=27); + if (numero==97) { + ventanaarchivo(0); + do { + textcolor(1);textbackground(1);gotoxy(78,24); + fflush(stdin);cscanf("%1c",&tecla);numero=tecla; + } while (numero!=115 && numero!=109 && numero!=108 && numero!=27); + if (numero==108) { + ventanageneral(0);ventana(35,5,8,8,"",8,24,11); + ventana(35,5,7,4,"Salir",14,22,10); + gotoxy(26,12);textbackground(7);textcolor(0); + cprintf("¨Desea salir del programa?"); + do { + textcolor(1);textbackground(1);gotoxy(78,24); + fflush(stdin);cscanf("%1c",&tecla);numero=tecla; + } while (numero!=115 && numero!=110 && numero!=27); + if (numero==115) + salir=1; + } + else { + if (numero==109) { + tipomatriz=ventanatipomatriz(); + ventanageneral(0); + switch(tipomatriz){ + case 49: + break; + case 50: + int matriz[3][3]; + ventana(20,7,8,8,"",8,9,6); + ventana(20,7,7,1,"Matriz",14,7,5); + gotoxy(11,6);textcolor(0);textbackground(7); + cprintf("Ú");gotoxy(11,7);cprintf("³");gotoxy(11,8);cprintf("³"); + gotoxy(11,9);cprintf("³");gotoxy(11,10);cprintf("À"); + gotoxy(22,6);cprintf("¿");gotoxy(22,7);cprintf("³"); + gotoxy(22,8);cprintf("³");gotoxy(22,9);cprintf("³"); + gotoxy(22,10);cprintf("Ù"); + for (int f=1;f<=3;f++) + for(int c=2;c<=9;c=c+3){ + gotoxy(12+c,6+f);cprintf("*"); + } + ventana(35,5,8,8,"",8,37,7); + ventana(35,5,7,1,"Introducci¢n de la matriz",14,35,6); + gotoxy(39,8);textcolor(0);textbackground(7); + cprintf("Introduce n£mero: "); + int num,col=0; + for (f=1;f<=3 && numero!=27;f++){ + for (col=(-1),c=2;c<=9 && numero!=27;col++){ + if (c>2){ + matriz[f-1][col]=num; + textcolor(0);gotoxy(12+(c-3),6+f); + cprintf("%d",matriz[f-1][col]); + textcolor(0+BLINK);gotoxy(12+c,6+f);cprintf("*"); + c=c+3; + } + else { + textcolor(0+BLINK);gotoxy(12+c,6+f);cprintf("*"); + c=c+3; + } + num=10; + do { + do { + if (numero==0) { + gotoxy(57,8);textcolor(7);cprintf("Û"); + } + textcolor(0);gotoxy(57,8); + fflush(stdin);cscanf("%1c",&tecla);numero=tecla; + if (numero==13 && num==10){ + num=0; + ventana(35,7,8,8,"",8,27,14); + ventana(35,7,7,4,"Error 002",14+BLINK,25,13); + textcolor(0);textbackground(7);gotoxy(29,15); + cprintf("Al no haber introducido nin-"); + gotoxy(29,16);cprintf("g£n valor, se introduce por"); + gotoxy(29,17);cprintf("defecto el 0."); + fflush(stdin);getch(); + ventana(35,7,15,15,"",15,27,14); + ventana(35,7,15,15,"",15,25,13); + } + if (numero!=27 && numero!=13 && numero<48 || numero>57) { + ventana(35,6,8,8,"",8,27,14); + ventana(35,6,7,4,"Error 001",14+BLINK,25,13); + textcolor(0);textbackground(7);gotoxy(29,15); + cprintf("No se puede introducir un"); + gotoxy(29,16);cprintf("car cter,solo n£meros."); + fflush(stdin);getch(); + ventana(35,6,15,15,"",15,27,14); + ventana(35,6,15,15,"",15,25,13); + numero=0; + } + }while(numero!=27 && numero!=13 && numero<48 || numero>57); + if (numero>=48 && numero<=57){ + switch(numero) { + case 48: + num=0;break; + case 49: + num=1;break; + case 50: + num=2;break; + case 51: + num=3;break; + case 52: + num=4;break; + case 53: + num=5;break; + case 54: + num=6;break; + case 55: + num=7;break; + case 56: + num=8;break; + case 57: + num=9;break; + } + } + }while(numero!=13 && numero!=27); + gotoxy(57,8);textcolor(7);cprintf("Û"); + } + matriz[f-1][col]=num; + textcolor(0);gotoxy(12+(c-3),6+f); + cprintf("%d",matriz[f-1][col]); + } + ventanageneral(1); + ventana(20,7,8,8,"",8,9,6); + ventana(20,7,7,1,"Matriz",14,7,5); + gotoxy(11,6);textcolor(0);textbackground(7); + cprintf("Ú");gotoxy(11,7);cprintf("³");gotoxy(11,8);cprintf("³"); + gotoxy(11,9);cprintf("³");gotoxy(11,10);cprintf("À"); + gotoxy(22,6);cprintf("¿");gotoxy(22,7);cprintf("³"); + gotoxy(22,8);cprintf("³");gotoxy(22,9);cprintf("³"); + gotoxy(22,10);cprintf("Ù"); + for (f=1;f<=3;f++){ + for (col=0,c=5;c<=9;c=c+3,col++){ + textcolor(0);gotoxy(12+(c-3),6+f); + cprintf("%d",matriz[f-1][col]); + } + textcolor(0);gotoxy(12+(c-3),6+f); + cprintf("%d",matriz[f-1][col]); + } + break; + } + do { + textcolor(1);textbackground(1);gotoxy(78,24); + fflush(stdin);cscanf("%1c",&tecla);numero=tecla; + } while (numero!=97 && numero!=121 && numero!=111 && numero!=27); + switch(numero){ + case 111: + ventanaoperaciones(); + getch(); + } + } + } + } + else { + if (numero==121) { + ventanaayuda(0); + do { + textcolor(1);textbackground(1);gotoxy(78,24); + fflush(stdin);cscanf("%1c",&tecla);numero=tecla; + } while (numero!=121 && numero!=97 && numero!=27); + if (numero==97) { + ventanageneral(0); + ventana(35,9,8,8,"",8,24,9); + ventana(35,9,7,1,"Acerca de...",14,22,8); + gotoxy(29,10);textbackground(7);textcolor(4+BLINK); + cprintf("MATRIMATIC© ver 1.0"); + gotoxy(25,12);textcolor(0);cprintf("Programado por:"); + gotoxy(27,13);textcolor(15);cprintf("Mois‚s Virumbrales Cuenca"); + gotoxy(40,15);textcolor(0);cprintf("Copyright 1999"); + fflush(stdin);getch(); + } + else { + if (numero==121) { + ventanageneral(0); + int numpag=1;char opcion='a'; + numpag=instrucciones(opcion,numpag); + for (;numpag!=10;) { + textcolor(1);textbackground(1);gotoxy(78,24); + fflush(stdin);cscanf("%1c",&opcion); + numpag=instrucciones(opcion,numpag); + } + } + } + } + else { + ventana(35,5,8,8,"",8,24,11); + ventana(35,5,7,4,"Salir",14,22,10); + gotoxy(26,12);textbackground(7);textcolor(0); + cprintf("¨Desea salir del programa?"); + do { + textcolor(1);textbackground(1);gotoxy(78,24); + fflush(stdin);cscanf("%1c",&tecla);numero=tecla; + } while (numero!=115 && numero!=110 && numero!=27); + if (numero==115) + salir=1; + } + } + textcolor(0); + } while(salir==0); +} + + + + +// Funci¢n ventana. +char ventana (int ancho,int largo,int color_g,int color_borde,char titulo[80], +int color_titulo,int posx,int posy) { + int x,y,cony,conx; + char dib; + dib='Û'; + for (cony=0,y=posy;cony +#include + +int con,sum,j,num,pant,conpag; +char pausa; +void main() +{ + clrscr(); + fflush (stdin); + gotoxy (20,12); + printf("Introduce un N£mero: "); + scanf ("%d", &num); + while (num < 1) + { + clrscr(); + fflush (stdin); + gotoxy (12,12); + printf("Introduce un N£mero correcto (mayor o igual que 1): "); + scanf ("%d", &num); + } + con=0; + sum=0; + j=7; + pant=0; + conpag=0; + clrscr(); + if (num>=j) + { + printf ("\t\t Lista de los m£ltiplos de siete entre 1 y %d.\n",num); + while (j<=num) + { + pant++; + if (pant<=219) + { + printf ("\t%d",j); + con++; + sum=sum+j; + j=j+7; + } + else + { + conpag++; + pant=0; + printf ("\n P gina: %d.\t\t\t\t\tPulsa ENTER para continuar...",conpag); + fflush (stdin); + scanf ("%c",&pausa); + clrscr(); + printf ("\t\t Lista de los m£ltiplos de siete entre 1 y %d.\n",num); + } + } + conpag++; + gotoxy (1,25); + printf (" P gina: %d.\t\t\t\t\tPulsa ENTER para continuar...",conpag); + fflush(stdin); + scanf("%c",&pausa); + clrscr(); + gotoxy (20,11); + if (con==1) + { + printf("Hay %d m£ltiplo de siete.",con); + } + else + { + printf("Hay %d m£ltiplos de siete.",con); + } + gotoxy (20,12); + printf("Su suma es: %d",sum); + fflush(stdin); + scanf("%c",&pausa); + } + else + { + clrscr(); + gotoxy (20,11); + printf("Hay %d m£ltiplos de siete.",con); + gotoxy (20,12); + printf("Su suma es: %d",sum); + fflush(stdin); + scanf("%c",&pausa); + } + clrscr(); +} \ No newline at end of file diff --git a/CPP/PROG3.CPP b/CPP/PROG3.CPP new file mode 100644 index 0000000..3449fb6 --- /dev/null +++ b/CPP/PROG3.CPP @@ -0,0 +1,105 @@ +// Prog3 +// +// Programadores: +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Pedir n£meros hasta que se introduzca un cero, y de todos los valores +// introducidos, calcular la media de los m£ltiplos de 5 menores que 500, +// sumar los impares comprendidos entre -10 y 10, contar los m£ltiplos de +// 13 y calcular la media de todos los n£meros introducidos. + +#include +#include + +int con,sum,con5,sum5,sumimpar,con13,num; +char pausa; + +void main() +{ + clrscr(); + gotoxy (20,13); + printf (" (Introduzca 0 para finalizar)"); + gotoxy (20,12); + printf (" Introduce un n£mero: "); + fflush(stdin); + scanf ("%d",&num); + while (num!=0) + { + if (num %5==0 && num <500) + { + con5++; + sum5=sum5+num; + } + + if (num>-10 && num<10 && num %2!=0) + { + sumimpar=sumimpar+num; + } + + if (num %13==0) + { + con13++; + } + + con++; + sum=sum +num; + clrscr(); + gotoxy (20,13); + printf (" (Introduzca 0 para finalizar)"); + gotoxy (20,12); + printf (" Introduce un n£mero: "); + fflush(stdin); + scanf ("%d",&num); + } + clrscr(); + + if (con==0) + { + gotoxy (20,12); + printf (" No se ha introducido ning£n n£mero."); + } + else + { + if (con5==0) + { + gotoxy (13,10); + printf (" No hay m£ltiplos de 5."); + } + else + { + gotoxy (13,10); + printf (" La media de los m£ltiplos de 5 menores que 500 es: "); + printf ("%d.",sum5/con5); + } + + if (sumimpar==0) + { + gotoxy (13,11); + printf (" No hay impares comprendidos entre -10 y 10."); + } + else + { + gotoxy (13,11); + printf (" La suma de los impares entre -10 y 10 es: %d.",sumimpar); + } + + if (con13==0) + { + gotoxy (13,12); + printf (" No hay m£ltiplos de 13."); + } + else + { + gotoxy (13,12); + printf (" Hay %d m£ltiplo(s) de 13.",con13); + } + + gotoxy (13,13); + printf (" La media de todos los n£meros introducidos es: %d.",sum/con); + } + + fflush (stdin); + scanf ("%c",&pausa); +} \ No newline at end of file diff --git a/CPP/PROG4.CPP b/CPP/PROG4.CPP new file mode 100644 index 0000000..e48aea6 --- /dev/null +++ b/CPP/PROG4.CPP @@ -0,0 +1,112 @@ +// Prog4 +// +// Programadores: +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Pedir n£meros hasta que se introduzca un cero. Imprimir el mayor de todos +// los pares y la posici¢n en que se introdujo, el menor de los m£ltiplos +// de 6 y la posici¢n en que se introdujo, el mayor de todos los valores +// y la posici¢n en que se introdujo. + +#include +#include + +int mayorpar,pospar,menor6,posmenor6,mayor,posmayor,con,num; +char pausa; + +void main() +{ + mayorpar=-32768;pospar=0;menor6=32767;posmenor6=0;mayor=-32768; + posmayor=0;con=0;num=0; + + clrscr(); + gotoxy (20,13); + printf (" (Introduzca 0 para finalizar)"); + gotoxy (20,12); + printf (" Introduce un n£mero: "); + fflush(stdin); + scanf ("%d",&num); + while (num!=0) + { + con++; + if (num %2==0 && num>mayorpar) + { + mayorpar=num; + pospar=con; + } + + if (num %6==0 && nummayor) + { + mayor=num; + posmayor=con; + } + + clrscr(); + gotoxy (20,13); + printf (" (Introduzca 0 para finalizar)"); + gotoxy (20,12); + printf (" Introduce un n£mero: "); + fflush(stdin); + scanf ("%d",&num); + } + + clrscr(); + + if (con==0) + { + gotoxy (20,12); + printf (" No se ha introducido ning£n n£mero."); + } + else + { + if (pospar==0) + { + gotoxy (15,11); + printf (" No se han introducido n£meros pares."); + } + else + { + gotoxy (15,10); + printf (" El mayor par introducido es: %d.",mayorpar); + gotoxy (15,11); + printf (" Se ha introducido en la %d¦ posici¢n.",pospar); + } + + if (posmenor6==0) + { + gotoxy (15,12); + printf (" No se han introducido m£ltiplos de 6."); + } + else + { + gotoxy (15,13); + printf (" El menor m£ltiplo de 6 introducido es: %d.",menor6); + gotoxy (15,14); + printf (" Se ha introducido en la %d¦ posici¢n.",posmenor6); + } + + if (posmayor==0) + { + gotoxy (15,13); + printf (" Los n£meros introducidos son iguales."); + } + else + { + gotoxy (15,16); + printf (" El mayor n£mero introducido es: %d.",mayor); + gotoxy (15,17); + printf (" Se ha introducido en la %d¦ posici¢n.",posmayor); + } + } + + fflush (stdin); + scanf ("%c",&pausa); +} \ No newline at end of file diff --git a/CPP/PROG5.CPP b/CPP/PROG5.CPP new file mode 100644 index 0000000..c1cba35 --- /dev/null +++ b/CPP/PROG5.CPP @@ -0,0 +1,96 @@ +// Prog5 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Pedir n£meros hasta que se introduzcan tres m£ltiplos de 7 (no +// necesariamente consecutivos) ¢ dos n£meros impares consecutivos. +// Imprimir el mayor valor introducido y su posici¢n. + +#include +#include + +int mayor,posmayor,con,con7,conimpar,sw,num; +char pausa; + +void main() +{ + mayor=-32768;posmayor=0;con=0,con7=0;conimpar=0;sw=0;num=0; + + clrscr(); + gotoxy (20,16); + printf ("(Para finalizar introduzca"); + gotoxy (20,17); + printf ("tres m£ltiplos de siete o"); + gotoxy (20,18); + printf ("dos impares consecutivos)"); + gotoxy (20,13); + printf (" Introduce un n£mero: "); + textcolor (4); + fflush(stdin); + cscanf ("%d",&num); + textcolor(7); + while (sw==0) + { + con++; + if (num %7==0) + { + con7++; + if (con7==3) + { + sw=1; + } + } + + if (num %2!=0) + { + conimpar++; + if (conimpar==2) + { + sw=1; + } + } + else + { + conimpar=0; + } + + if (num>mayor) + { + mayor=num; posmayor=con; + } + + if (sw==0) + { + clrscr(); + gotoxy (20,16); + printf ("(Para finalizar introduzca"); + gotoxy (20,17); + printf ("tres m£ltiplos de siete o"); + gotoxy (20,18); + printf ("dos impares consecutivos)"); + gotoxy (20,13); + printf (" Introduce un n£mero: "); + textcolor (4); + fflush(stdin); + cscanf ("%d",&num); + textcolor(7); + } + } + + clrscr(); + gotoxy (20,12); + printf (" El mayor n£mero introducido es: "); + textcolor (14); + cprintf ("%d",mayor); + printf ("."); + gotoxy (20,13); + printf (" Se ha introducido en la "); + cprintf ("%d¦",posmayor); + printf (" posici¢n."); + fflush (stdin); + scanf ("%c",&pausa); +} \ No newline at end of file diff --git a/CPP/PROG6.CPP b/CPP/PROG6.CPP new file mode 100644 index 0000000..5394aa2 --- /dev/null +++ b/CPP/PROG6.CPP @@ -0,0 +1,177 @@ +// Prog6 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Imprime una pir mide de asteriscos seg£n las opciones tecleadas +// por el usuario. +// +// Descripci¢n de las variables: +// num: N£mero de asteriscos de la base. +// altura: N£mero de filas de la pir mide. +// posx, posy: Posici¢n del cursor para imprimir asteriscos. +// conposx: Contador que lleva el n£mero de asteriscos imprimidos por fila. +// conposy: Contador que lleva el n£mero de filas imprimidas. +// color, color2, colorg: Guarda colores introducidos por usuario. +// conveces: Cuenta las veces que se introduce un color +// nveces: Marca las veces que se realiza el bucle dependiendo si es +// Monocolor o Bicolor. +// tipo: Tipo de pir mide (normal o invertida) +// pausa: Para hacer una pausa al final del programa. +// ncolores: Guarda si es Monocolor o Bicolor. +// tipocolor: Forma de colorearlo (por filas o asteriscos). + + + +#include +#include + +int num; +int altura; +int posx,posy; +int conposx,conposy; +int color,color2,colorg; +int conveces,nveces; +char tipo,pausa,ncolores,tipocolor; + +void main() +{ + + do + { + clrscr(); + gotoxy (17,13); + printf ("Introduce el N§ de asteriscos de la base: "); + fflush (stdin); + scanf ("%d",&num); + } + while (num %2!=0 || num<1 || num>50); + + do + { + clrscr(); + gotoxy(20,12); + printf (" Tipo de pir mide (Normal o Invertida): "); + fflush (stdin); + scanf ("%c",&tipo); + } + while (tipo!='n' && tipo!='i'); + + do + { + clrscr(); + gotoxy (20,12); + printf (" Monocolor o Bicolor: "); + fflush (stdin); + scanf ("%c",&ncolores); + } + while (ncolores!='m' && ncolores!='b'); + + if (ncolores=='m') + { + nveces=1; + } + else + { + nveces=2; + + do + { + clrscr(); + gotoxy(20,12); + printf (" Colorear por Filas o por Asteriscos: "); + fflush(stdin); + scanf ("%c",&tipocolor); + } + while (tipocolor!='f' && tipocolor!='a'); + } + + conveces=1; + + do + { + if (nveces==2) + { + color2=color; + } + + clrscr(); + gotoxy (25,8); printf (" 1.- Azul"); + gotoxy (25,9); printf (" 2.- Verde"); + gotoxy (25,10); printf (" 3.- Cyan"); + gotoxy (25,11); printf (" 4.- Rojo"); + gotoxy (25,12); printf (" 5.- Morado"); + gotoxy (25,13); printf (" 6.- Marr¢n"); + gotoxy (25,14); printf (" 7.- Gris claro"); + gotoxy (25,15); printf (" 8.- Gris oscuro"); + gotoxy (25,16); printf (" 9.- Azul claro"); + gotoxy (25,17); printf ("10.- Verde claro"); + gotoxy (25,18); printf ("11.- Cyan claro"); + gotoxy (25,19); printf ("12.- Rojo claro"); + gotoxy (25,20); printf ("13.- Morado claro"); + gotoxy (25,21); printf ("14.- Amarillo"); + gotoxy (25,22); printf ("15.- Blanco"); + gotoxy (20,6); + printf (" Elige color %d§: ",conveces); + fflush(stdin); + scanf ("%d",&color); + conveces++; + } + while (color<1 || color>15 || conveces<=nveces); + + altura=(num/2); + posx=((80-num)/2); + + if (tipo=='n') + { + posy=(25-((25-altura)/2)); + } + else + { + posy=((26-(altura-1))/2); + } + + clrscr(); + textcolor(color); + + for (conposy=1;conposy<=altura;conposy++) + { + gotoxy(posx,posy); + + if (tipocolor=='f') + { + colorg=color;color=color2;color2=colorg; + textcolor(colorg); + } + + for (conposx=1;conposx<=num;conposx++) + { + if (tipocolor=='a') + { + colorg=color;color=color2;color2=colorg; + textcolor (colorg); + } + + cprintf ("*"); + } + + if (tipo=='n') + { + posy--; + } + else + { + posy++; + } + num=num-2; + posx++; + } + + textcolor(7); + gotoxy(80,25); + fflush (stdin); + scanf ("%c",&pausa); +} \ No newline at end of file diff --git a/CPP/PROG7.CPP b/CPP/PROG7.CPP new file mode 100644 index 0000000..fb6e067 --- /dev/null +++ b/CPP/PROG7.CPP @@ -0,0 +1,124 @@ +// Prog7 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Pinta una espiral con el caracter introducido y pinta sus diagonales. +#include +#include +char direccion; +char caracter; +int pos_x,pos_y,avanza,con,veces,avanzamas,sw; + +void main() +{ + clrscr(); + gotoxy (20,11); + printf ("Introduzca el car cter a imprimir: "); + fflush (stdin); + cscanf ("%c", &caracter); + //gotoxy (20,12); + //printf ("Introduzca el sentido inicial: "); + //fflush(stdin); + //scanf("%c",&direccion_inicial); + clrscr(); + direccion='e'; + pos_x=40; + pos_y=12; + avanza=1; + //avanzamas=15; + gotoxy (pos_x,pos_y); + printf ("%c",caracter); + do + { + for (con=1;con<=2;con++) + { + for (veces=1;direccion=='e' && veces<=avanza;veces++) + { + gotoxy(pos_x,pos_y); + printf("%c",caracter); + pos_x++; + if (pos_x==50) + { + sw=1; + direccion='p'; + } + } + for (veces=1;direccion=='o' && veces<=avanza;veces++) + { + gotoxy(pos_x,pos_y); + printf("%c",caracter); + pos_x--; + } + for (veces=1;direccion=='n' && veces<=avanza;veces++) + { + gotoxy(pos_x,pos_y); + printf("%c",caracter); + pos_y--; + } + for (veces=1;direccion=='s' && veces<=avanza;veces++) + { + gotoxy(pos_x,pos_y); + printf("%c",caracter); + pos_y++; + } + getch(); +// Cambio de direcciones. + if (direccion=='e') + { + direccion='s'; + } + else + { + if (direccion=='o') + { + direccion='n'; + } + else + { + if (direccion=='n') + { + direccion='e'; + } + else + { + if (direccion=='s') + { + direccion='o'; + } + } + } + } + } + //avanzamas++; + avanza++; + } + while (sw==0); + gotoxy(80,25); + getch(); + pos_x=31; + pos_y=3; + for(con=1;con<=19;con++,pos_x++,pos_y++) + { + gotoxy (pos_x,pos_y); + textcolor(14); + cprintf ("%c",caracter); + } + getch(); + pos_x=49; + pos_y=3; + for(con=1;con<=19;con++,pos_x--,pos_y++) + { + if (pos_x!=40) + { + gotoxy (pos_x,pos_y); + textcolor(1); + cprintf ("%c",caracter); + } + } + getch(); + +} \ No newline at end of file diff --git a/CPP/PROG8.CPP b/CPP/PROG8.CPP new file mode 100644 index 0000000..5b43f2e --- /dev/null +++ b/CPP/PROG8.CPP @@ -0,0 +1,63 @@ +// Prog8 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// + +#include +#include +char direccion; +char caracter; +int pos_x,pos_y,con; + +void main() +{ + clrscr(); + gotoxy (20,11); + printf ("Introduzca el car cter a imprimir: "); + fflush (stdin); + cscanf ("%c", &caracter); + clrscr(); + direccion='d'; + pos_x=1; + pos_y=1; + for (;pos_y<=24;pos_y++) + { + for (con=1;con<=80;con++) + { + if (direccion=='d') + { + gotoxy(pos_x,pos_y); + printf ("%c",caracter); + pos_x++; + } + else + { + gotoxy(pos_x,pos_y); + printf ("%c",caracter); + pos_x--; + } + if (con==40) + { + getch(); + } + } + getch(); + if (direccion=='d') + { + direccion='i'; + pos_x--; + } + else + { + direccion='d'; + pos_x++; + } + } + gotoxy(1,25); + printf ("Pulse una tecla para finalizar..."); + getch(); +} \ No newline at end of file diff --git a/CPP/PROG9.CPP b/CPP/PROG9.CPP new file mode 100644 index 0000000..051c558 --- /dev/null +++ b/CPP/PROG9.CPP @@ -0,0 +1,613 @@ +// Prog9 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Juego de las tres en raya. + + +#include +#include + +int pos_x,pos_y,jfila,jcolumna; +int sw1,sw2,sw3,sw4,sw5,sw6,sw7,sw8,sw9; +int con,conaux; +int turno,turnoaux; +int lugar,tablalugar [3][3]; +int ganar; +int vaciaf,vaciac; +char jugador1[8],jugador2[8]; +char continua; +int limpia; +char fichaX [5][5],ficha0 [5][5]; +int win1,win2; + +void main() +{ + +// Inicializaci¢n de funciones. + +char pintar(int pos_x,int pos_y, int turno, int color); +char tablero(); +char borrar(int pos_y); +int comprobar(int turno); +char leerdatos(); +char pantalla(char jugador1[8],char jugador2[8]); + +// Inicializaci¢n de la ficha X. + fichaX [0][0]='Û';fichaX [0][4]='Û';fichaX [1][1]='Û';fichaX [1][3]='Û'; + fichaX [3][1]='Û';fichaX [3][3]='Û';fichaX [4][0]='Û';fichaX [4][4]='Û'; + fichaX [2][2]='Û'; +// Inicializaci¢n de la ficha 0. + ficha0 [0][2]='Û';ficha0 [1][1]='Û';ficha0 [1][3]='Û';ficha0 [2][0]='Û'; + ficha0 [2][4]='Û';ficha0 [3][1]='Û';ficha0 [3][3]='Û';ficha0 [4][2]='Û'; +// Introducci¢n de datos + + leerdatos(); + do + { + +// Pantalla general + if (continua!='s') + { + pantalla(jugador1,jugador2); + } + tablero(); + if (turno==1 && continua=='s') + { + if (ganar==1) + { + win1++; + gotoxy (17,2); + printf ("Partidas ganadas: %d",win1); + } + turno=2; + borrar(24); + textcolor (7); + gotoxy (17,24); + cprintf ("Es el turno de "); + textcolor(2+BLINK); + cprintf ("%s",jugador2); + } + else + { + if (turno==2 && continua=='s') + { + if (ganar==2) + { + win2++; + gotoxy (45,2); + printf ("Partidas ganadas: %d",win2); + } + turno=1; + borrar(24); + textcolor (7); + gotoxy (17,24); + cprintf ("Es el turno de "); + textcolor(14+BLINK); + cprintf ("%s",jugador1); + } + } +// El programa. + + for (vaciaf=0;vaciaf<3;vaciaf++) + { + for (vaciac=0;vaciac<3;vaciac++) + { + tablalugar[vaciaf][vaciac]=0; + } + } + sw1=0;sw2=0;sw3=0;sw4=0;sw5=0;sw6=0;sw7=0;sw8=0;sw9=0; + conaux=1; + lugar=0; + for (con=1,ganar=0;con<=9;con++) + { + con=conaux; + gotoxy (79,25); + fflush(stdin); + textcolor(0); + cscanf("%1d",&lugar); + + if (lugar==1 && sw1==0) + { + pos_x=22;pos_y=17; + sw1=1; + if (turno==1) + { + tablalugar [0][2]=1; + } + else + { + tablalugar [0][2]=2; + } + } + else + { + if (lugar==2 && sw2==0) + { + pos_x=38;pos_y=17; + sw2=1; + if (turno==1) + { + tablalugar [1][2]=1; + } + else + { + tablalugar [1][2]=2; + } + } + else + { + if (lugar==3 && sw3==0) + { + pos_x=54;pos_y=17; + sw3=1; + if (turno==1) + { + tablalugar [2][2]=1; + } + else + { + tablalugar [2][2]=2; + } + } + else + { + if (lugar==4 && sw4==0) + { + pos_x=22;pos_y=11; + sw4=1; + if (turno==1) + { + tablalugar [0][1]=1; + } + else + { + tablalugar [0][1]=2; + } + } + else + { + if (lugar==5 && sw5==0) + { + pos_x=38;pos_y=11; + sw5=1; + if (turno==1) + { + tablalugar [1][1]=1; + } + else + { + tablalugar [1][1]=2; + } + } + else + { + if (lugar==6 && sw6==0) + { + pos_x=54;pos_y=11; + sw6=1; + if (turno==1) + { + tablalugar [2][1]=1; + } + else + { + tablalugar [2][1]=2; + } + } + else + { + if (lugar==7 && sw7==0) + { + pos_x=22;pos_y=5; + sw7=1; + if (turno==1) + { + tablalugar [0][0]=1; + } + else + { + tablalugar [0][0]=2; + } + } + else + { + if (lugar==8 && sw8==0) + { + pos_x=38;pos_y=5; + sw8=1; + if (turno==1) + { + tablalugar [1][0]=1; + } + else + { + tablalugar [1][0]=2; + } + } + else + { + if (lugar==9 && sw9==0) + { + pos_x=54;pos_y=5; + sw9=1; + if (turno==1) + { + tablalugar [2][0]=1; + } + else + { + tablalugar [2][0]=2; + } + } + else + { + borrar (24); + textcolor (7); + gotoxy (17,24); + cprintf ("Esa casilla est  ocupada, pierde turno."); + fflush (stdin); + getch(); + conaux=con; + turnoaux=turno; + turno=0; + } + } + } + } + } + } + } + } + } + comprobar(turno); + + + +// Pintar la ficha correspondiente. + + if (turno==1 && ganar==0) + { + pintar(pos_x,pos_y,turno,14); + } + else + { + if (turno==2 && ganar==0) + { + pintar(pos_x,pos_y,turno,2); + } + } +// Siguiente turno. + + if (turno==2 && con!=9 && ganar==0) + { + borrar(24); + textcolor (7); + gotoxy (17,24); + cprintf ("Es el turno de "); + textcolor(14+BLINK); + cprintf ("%s",jugador1); + turno=1; + conaux++; + } + else + { + if (turno==1 && con!=9 && ganar==0) + { + borrar(24); + textcolor (7); + gotoxy (17,24); + cprintf ("Es el turno de "); + textcolor(2+BLINK); + cprintf ("%s",jugador2); + turno=2; + conaux++; + } + else + { + if (turnoaux==2 && con!=9 && ganar==0) + { + borrar(24); + textcolor (7); + gotoxy (17,24); + cprintf ("Es el turno de "); + textcolor(14+BLINK); + cprintf ("%s",jugador1); + turno=1; + } + else + { + if (turnoaux==1 && con!=9 && ganar==0) + { + borrar(24); + textcolor (7); + gotoxy (17,24); + cprintf ("Es el turno de "); + textcolor(2+BLINK); + cprintf ("%s",jugador2); + turno=2; + } + } + } + } + if (con==9 && ganar==0) + { + borrar(24); + gotoxy (17,24); + textcolor(7); + cprintf ("Partida finalizada."); + fflush(stdin); + getch(); + } + if (ganar==1) + { + borrar(24); + gotoxy (17,24); + textcolor (14+BLINK); + cprintf ("­­ Ha ganado %s !!",jugador1); + con=10; + fflush (stdin); + getch(); + } + else + { + if (ganar==2) + { + borrar(24); + gotoxy (17,24); + textcolor (10+BLINK); + cprintf ("­­ Ha ganado %s !!",jugador2); + con=10; + fflush (stdin); + getch(); + } + } + } + borrar(24); + gotoxy (17,24); + textcolor(7); + cprintf ("¨Desea jugar otra vez? "); + fflush(stdin); + cscanf ("%s",&continua); + } + while (continua!='n'); + fflush (stdin); + getch(); + clrscr(); + textcolor (7); +} + +// Funci¢n pintar + +char pintar(int pos_x,int pos_y,int turno,int color) +{ + for (jfila=0;jfila<=4;jfila++) + { + for (jcolumna=0;jcolumna<=4;jcolumna++) + { + gotoxy (jcolumna+pos_x,jfila+pos_y); + if (turno==1) + { + if (fichaX[jfila][jcolumna]=='Û') + { + textcolor (color); + cprintf ("%c",fichaX[jfila][jcolumna]); + } + } + else + { + if (turno==2) + { + if (ficha0[jfila][jcolumna]=='Û') + { + textcolor (color); + cprintf ("%c",ficha0[jfila][jcolumna]); + } + } + } + } + + } + return(0); +} + +// Funci¢n tablero + +char tablero() +{ + // Fondo tablero. + for (pos_x=15,pos_y=4;pos_y<=22;) + { + textcolor(7); + gotoxy(pos_x,pos_y); + cprintf("Û"); + if (pos_x!=65) + { + pos_x++; + } + else + { + pos_x=15; + pos_y++; + } + } +// Recuadro tablero y lineas interior. + for (pos_x=15;pos_x<=65;pos_x++) + { + textcolor (1); + gotoxy (pos_x,4);cprintf ("Û"); + gotoxy (pos_x,22);cprintf ("Û"); + gotoxy (pos_x,10);cprintf ("Û"); + gotoxy (pos_x,16);cprintf ("Û"); + } + for (pos_y=4;pos_y<=22;pos_y++) + { + textcolor (1); + gotoxy (15,pos_y);cprintf ("Û"); + gotoxy (16,pos_y);cprintf ("Û"); + gotoxy (65,pos_y);cprintf ("Û"); + gotoxy (64,pos_y);cprintf ("Û"); + gotoxy (32,pos_y);cprintf ("Û"); + gotoxy (48,pos_y);cprintf ("Û"); + } + + return(0); +} + +// Borrador de l¡nea +char borrar(int pos_y) +{ + for (limpia=1;limpia<=80;limpia++) + { + gotoxy (limpia,pos_y); + textcolor (0); + cprintf ("Û"); + } + return (0); +} + +// Comprobaci¢n de tres en raya + +int comprobar(int turno) +{ + if (turno!=0) + { + if (tablalugar[0][0]==turno) + { + if (tablalugar[1][0]==turno) + { + if (tablalugar[2][0]==turno) + { + ganar=turno; + pintar(22,5,turno,4+BLINK);pintar(38,5,turno,4+BLINK); + pintar(54,5,turno,4+BLINK); + } + } + else + { + if (tablalugar[1][1]==turno) + { + if (tablalugar[2][2]==turno) + { + ganar=turno; + pintar(22,5,turno,4+BLINK);pintar(38,11,turno,4+BLINK); + pintar(54,17,turno,4+BLINK); + } + } + else + { + if (tablalugar[0][1]==turno) + { + if (tablalugar[0][2]==turno) + { + ganar=turno; + pintar(22,5,turno,4+BLINK);pintar(22,11,turno,4+BLINK); + pintar(22,17,turno,4+BLINK); + } + } + } + } + } + if (tablalugar[2][0]==turno) + { + if (tablalugar[2][1]==turno) + { + if (tablalugar[2][2]==turno) + { + ganar=turno; + pintar(54,5,turno,4+BLINK);pintar(54,11,turno,4+BLINK); + pintar(54,17,turno,4+BLINK); + } + } + else + { + if (tablalugar[1][1]==turno) + { + if (tablalugar[0][2]==turno) + { + ganar=turno; + pintar(54,5,turno,4+BLINK);pintar(38,11,turno,4+BLINK); + pintar(22,17,turno,4+BLINK); + } + } + } + } + if (tablalugar[2][2]==turno) + { + if (tablalugar[1][2]==turno) + { + if (tablalugar[0][2]==turno) + { + ganar=turno; + pintar(22,17,turno,4+BLINK);pintar(38,17,turno,4+BLINK); + pintar(54,17,turno,4+BLINK); + } + } + } + if (tablalugar[1][0]==turno) + { + if (tablalugar[1][1]==turno) + { + if (tablalugar[1][2]==turno) + { + ganar=turno; + pintar(38,5,turno,4+BLINK);pintar(38,11,turno,4+BLINK); + pintar(38,17,turno,4+BLINK); + } + } + } + if (tablalugar[0][1]==turno) + { + if (tablalugar[1][1]==turno) + { + if (tablalugar[2][1]==turno) + { + ganar=turno; + pintar(22,11,turno,4+BLINK);pintar(38,11,turno,4+BLINK); + pintar(54,11,turno,4+BLINK); + } + } + } + } + return(ganar); +} + +// Datos + +char leerdatos() +{ + clrscr(); + textcolor(7); + gotoxy (20,11); + cprintf ("Nombre jugador 1: "); + fflush(stdin); + cscanf("%8s",&jugador1); + gotoxy (20,13); + cprintf ("Nombre jugador 2: "); + fflush(stdin); + cscanf("%8s",&jugador2); + return (jugador1[8],jugador2[8]); +} + +// Pantalla general + +char pantalla(char jugador1[8],char jugador2[8]) +{ + clrscr(); + gotoxy (17,1); + textcolor(14); + cprintf ("X ");textcolor (7);cprintf ("-> %s",jugador1); + gotoxy (53,1); + textcolor (2); + cprintf ("O ");textcolor (7);cprintf ("-> %s",jugador2); + gotoxy (17,24); + printf ("Es el turno de "); + textcolor(14+BLINK); + cprintf ("%s",jugador1); + turno=1; + return(turno); +} \ No newline at end of file diff --git a/CPP/PRUEBA.C b/CPP/PRUEBA.C new file mode 100644 index 0000000..e1d8f49 --- /dev/null +++ b/CPP/PRUEBA.C @@ -0,0 +1,5 @@ +#include + +void main(){ + printf("Hola Mundo"); +} diff --git a/CPP/PRUEBA.CPP b/CPP/PRUEBA.CPP new file mode 100644 index 0000000..96119bf --- /dev/null +++ b/CPP/PRUEBA.CPP @@ -0,0 +1,59 @@ +// Prog10 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// +// Program que introducido un n£mero decimal, lo cambia a la base +// introducida. + +#include +#include + +#define A 10 +#define B 11 +#define C 12 +#define D 13 +#define E 14 +#define F 15 +#define a 10 +#define b 11 +#define c 12 +#define d 13 +#define e 14 +#define f 15 + +int tabla[15]; +void leer_datos (); + +void main () { +leer_datos; +//verificar +//pasar_base10 +//pasar_base_elegida +//mostrar_resultados +fflush(stdin); +getch(); +} + +// Funci¢n de leer datos. +void leer_datos () { + + int num,con=0; + do { + fflush(stdin); + cscanf("%1d",&num); + if (num>=0 && num <=15) { + tabla[con]=num; + con++; + } + } + while (num<=0 && num >=15 && con >15); + +} + + + + diff --git a/CPP/PRUEBA.E b/CPP/PRUEBA.E new file mode 100644 index 0000000..70f562c Binary files /dev/null and b/CPP/PRUEBA.E differ diff --git a/CPP/PRUEBA.O b/CPP/PRUEBA.O new file mode 100644 index 0000000..5125180 Binary files /dev/null and b/CPP/PRUEBA.O differ diff --git a/CPP/PUNTERO.CPP b/CPP/PUNTERO.CPP new file mode 100644 index 0000000..bc40a97 --- /dev/null +++ b/CPP/PUNTERO.CPP @@ -0,0 +1,39 @@ +#include +#include +#include + +void borrar(int pos_y); + +void main(){ + int i=0,*p,tabla[10];int x,y; + textcolor(7);textbackground(0); + clrscr(); + for (i=0;i<10;i++) + tabla[i]=i+1; + for (i=0;i<10;i++){ + printf("\n Inizializaci¢n de la cuenta atras... %2d",tabla[i]);delay(100); + } + printf("\n"); + p=&tabla[9]; + for (;p>=&tabla[0];p--){ + printf("\n Cuenta atras... %2d",*p);delay(1000); + } + printf("\n\n CERO, DESPEGUE"); + for (i=60;i>1;i--){ + printf(".");delay(i); + if (i==50){ + x=wherex();y=wherey(); + gotoxy(3,25);textcolor(12+BLINK);cprintf("Lo perdemos, lo perdemos..."); + gotoxy(x,y); + } + } + borrar(25);textcolor(7);gotoxy(3,24);cprintf(" Se nos fue..."); + getch(); +} +void borrar(int pos_y){ + for (int limpia=1;limpia<=80;limpia++){ + gotoxy (limpia,pos_y); + textcolor (0); + cprintf ("Û"); + } +} diff --git a/CPP/SEPETA.CPP b/CPP/SEPETA.CPP new file mode 100644 index 0000000..f5a16a6 --- /dev/null +++ b/CPP/SEPETA.CPP @@ -0,0 +1,20 @@ +// PROGRAMA QUE IMPLEMENTA LAS FUNCIONES + +#include +#include + +char var,c; +void main() +{ + + textbackground(2); + clrscr(); + textcolor(4); + gotoxy(20,10); + cprintf("Hola Tron, dame un valor: "); + cscanf("%c", &var); + gotoxy(20,12); + printf("El valor es: %c",var); + scanf("%c",&c); + +} diff --git a/CPP/TEMP.CPP b/CPP/TEMP.CPP new file mode 100644 index 0000000..f490864 --- /dev/null +++ b/CPP/TEMP.CPP @@ -0,0 +1,102 @@ +// Prog7 +// +// Programadores: +// +// Juan L¢pez Fern ndez +// Mois‚s Virumbrales Cuenca +// DAI 1§A +// + +#include +#include + +char direccion; +char caracter; +int pos_x,pos_y,avanza,con,veces; + +void main() +{ + clrscr(); + gotoxy (20,11); + printf ("Introduzca el car cter a imprimir: "); + fflush (stdin); + cscanf ("%c", &caracter); + //gotoxy (20,12); + //printf ("Introduzca el sentido inicial: "); + //fflush(stdin); + //scanf("%c",&direccion_inicial); + clrscr(); + direccion='e'; + pos_x=40; + pos_y=12; + avanza=1; + gotoxy (pos_x,pos_y); + printf ("%c",caracter); + textcolor(14); + do + { + for (con=1;con<=2;con++) + { + for (veces=1;direccion=='e' && veces<=avanza;veces++) + { + gotoxy(pos_x,pos_y); + textcolor(2); + cprintf("%c",caracter); + pos_x++; + } + for (veces=1;direccion=='o' && veces<=avanza;veces++) + { + gotoxy(pos_x,pos_y); + textcolor(14); + cprintf("%c",caracter); + pos_x--; + } + for (veces=1;direccion=='n' && veces<=avanza;veces++) + { + gotoxy(pos_x,pos_y); + textcolor(13); + cprintf("%c",caracter); + pos_y--; + } + for (veces=1;direccion=='s' && veces<=avanza;veces++) + { + gotoxy(pos_x,pos_y); + textcolor(12); + cprintf("%c",caracter); + pos_y++; + } + getch(); +// Cambio de direcciones. + if (direccion=='e') + { + direccion='s'; + } + else + { + if (direccion=='o') + { + direccion='n'; + } + else + { + if (direccion=='n') + { + direccion='e'; + } + else + { + if (direccion=='s') + { + direccion='o'; + } + } + } + } + } + avanza++; + } + while (pos_y>0); + gotoxy(80,25); + getch(); + +} \ No newline at end of file diff --git a/CPP/TEST.CPP b/CPP/TEST.CPP new file mode 100644 index 0000000..4888d38 --- /dev/null +++ b/CPP/TEST.CPP @@ -0,0 +1,128 @@ +// ************************************************************************************************ +// +// Direct X TEST. +// +// ************************************** (c) Pedro Díez López ************************************ + +#include "DXVideo.h" + +#define ID_NOMBRE "Test" +#define ID_TITULO "Test" +#define ID_TEMP 1 + +CDXVideo *DXVideo; +BOOL Par; +int Temporizador; +BOOL AppActiva; + +// +// El TEST +// +void Test () +{ + if(Par==TRUE) + { + memset(DXVideo->pBuffer.bpp,064,DXVideo->DimBuffer); + Par = FALSE; + } + else + { + memset(DXVideo->pBuffer.bpp,128,DXVideo->DimBuffer); + Par = TRUE; + } +} + +// +// +// W i n d o w P r o c +// +// +long FAR PASCAL WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch( message ) + { + case WM_ACTIVATEAPP: + AppActiva = (wParam == WA_ACTIVE) || (wParam == WA_CLICKACTIVE); + break; + + case WM_CREATE: + break; + + case WM_SETCURSOR: + SetCursor(DXVideo->mDDCursorShape); + return TRUE; + + case WM_TIMER: + if (AppActiva && ID_TEMP == wParam) + { + Test(); + DXVideo->Pinta(); + } + break; + + case WM_KEYDOWN: + switch( wParam ) + { + case VK_ESCAPE: + PostMessage(hWnd, WM_CLOSE, 0, 0); + break; + } + break; + + case WM_PAINT: + break; + + case WM_DESTROY: + DXVideo->Fin(); + delete DXVideo; + PostQuitMessage(0); + break; + } + return DefWindowProc(hWnd, message, wParam, lParam); +} + +// +// +// W i n M a i n +// +// +int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + WNDCLASS wc; + HWND hwnd; + MSG msg; + + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = WindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = ID_NOMBRE; + wc.lpszClassName = ID_NOMBRE; + RegisterClass(&wc); + + hwnd = CreateWindowEx(WS_EX_TOPMOST,ID_NOMBRE,ID_TITULO,WS_POPUP,0,0, + GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN), + NULL, NULL, hInstance, NULL); + if (!hwnd) return FALSE; + ShowWindow(hwnd, nCmdShow); + UpdateWindow(hwnd); + + Temporizador = 100; + if(!SetTimer(hwnd,ID_TEMP,Temporizador,NULL)) return FALSE; + + DXVideo = new CDXVideo; + DXVideo->Inicio (hwnd,640,480,16); + DXVideo->Cursor(NULL); + + while (GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return msg.wParam; +} diff --git a/CPP/VENTANA.CPP b/CPP/VENTANA.CPP new file mode 100644 index 0000000..beb2154 --- /dev/null +++ b/CPP/VENTANA.CPP @@ -0,0 +1,36 @@ +#include +#include + +char ventana (int ancho,int largo,int color_g,int color_borde,char titulo, +int color_titulo,int posx,int posy); + +void main() { + clrscr(); + ventana(40,10,7,1,'P',14,30,7); + fflush(stdin); + getch(); +} + +// Funci¢n ventana. +char ventana (int ancho,int largo,int color_g,int color_borde,char titulo, +int color_titulo,int posx,int posy) { + int x,y,cony,conx; + char dib; + dib='Û'; + for (cony=0,y=posy;cony +#include +#include +#include +#include +#include +#include "d:\progs_c\gui.h" + +char titulo[80]={"Programa Gesti¢n del VideoClub Alfa. Juan L¢pez Fern ndez"}; + +int estoy_en=1;// Indica el men£ en el que me encuentro. +int select_actual=1; // Indica que opci¢n est  seleccionada actualmente. +int n_op_menu=5; // N£mero de opciones del menu. (default menu1=5) +int refresco=1; // Para el calor... Refresca la pantalla :-). + +int *p_estoy_en=&estoy_en;// -- Punteros a sus respectivas variables. -- +int *p_select_actual=&select_actual; +int *p_n_op_menu=&n_op_menu; +int *p_refresco=&refresco; + +// -------- Definici¢n de los patrones o "templates" --------------------- +struct peliculas { + char titulo[20]; + char tema[10]; + int duracion; + int n_alquileres; +}; +struct clientes { + int codigo; + char nombre[25]; +}; +struct alquileres { + struct peliculas lista_pelis[5]; + struct clientes socios; + float fecha_dev; + char finalizado; +}; +// ---------------- Fin de la definici¢n de los patrones. ----------------- + +struct peliculas existencias[230]; // Declaraci¢n de arrays +struct clientes socios[100]; // de estructuras. +struct alquileres prestamos[100]; // A nivel global. + + +void modo_grafico(); +void menu(int, int); +void miga(int*, int*); +void localizacion(int, int, int); +void reloj(int, int); + +void introcad(char cad[],int a,int x,int y,int c,int s,int t); +void altas_clientes(int); +//int bajas_clientes(struct, int, int); +//void modificar_clientes(struct, int, int); + +// *********************************************************************** +// PROGRAMA PRINCIPAL +// *********************************************************************** +void main() { + +// struct peliculas existencias[500]; // probablemente no est‚ aqu¡. +// struct clientes socios[200]; +// struct alquileres prestamos[200]; + // <..inicializar las tablas..>. + + modo_grafico(); + //presentacion(); // Me pregunto si llegar‚ a hacerla... ;-). + menu(estoy_en, select_actual); + int tecla1, tecla12, sw=1; + + while(sw==1){ + reloj(423,100); + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (select_actual<=1) + select_actual=1; + else { + select_actual--; + menu(estoy_en, select_actual); + } + break; + case 80: // Flecha abajo + if (select_actual>=n_op_menu) + select_actual=n_op_menu; + else{ + select_actual++; + menu(estoy_en, select_actual); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + miga(p_estoy_en, p_select_actual); + menu(estoy_en, select_actual); + } + else + if (tecla1==27) + if (estoy_en==1) // Se acab¢ la funci¢n... + sw=0; + else // Navegaci¢n descendente por men£s. + + { + *p_estoy_en/=10; + *p_n_op_menu=5; + *p_select_actual=1; + *p_refresco=1; + menu(estoy_en,select_actual); + } + } // fin del while + +// getch(); + closegraph(); +} + +// *********************************************************************** +// --- FUNCIONES DEL PROGRAMA --- +// *********************************************************************** + +// ------------------------------------------------------------------------ +// FUNCIàN MIGA (MIGA DEL ASUNTO) +// (con punteros!, como mola...) +// ------------------------------------------------------------------------ +void miga(int *p_estoy_en,int *p_select_actual) { + + *p_refresco=1; // antes de nada tomemos una coca-cola... ;-) + + switch (*p_estoy_en) // veamos que hay que hacer: + { + case 1: // naveguemos por los men£s: ir a menu 1.x + switch (*p_select_actual) + { + case 1: + *p_estoy_en=11; + *p_select_actual=1; + *p_n_op_menu=5; + break; + case 2: + *p_estoy_en=12; + *p_select_actual=1; + *p_n_op_menu=5; + break; + case 3: + *p_estoy_en=13; + *p_select_actual=1; + *p_n_op_menu=3; + break; + case 4: + *p_estoy_en=14; + *p_select_actual=1; + *p_n_op_menu=3; + break; + } // fin del switch-case(select_actual) de navegaci¢n de men£s. + break;//fin del case 1 general. + + case 11: // Estamos en las opciones del menu1. + switch (select_actual) // veamos que hay que hacer. + { + case 1: // ALTAS DE CLIENTES. + altas_clientes(200); + break; + } + break; + } // fin del switch-case(estoy_en) general (TOCHO). +} // fin de la funci¢n miga + +// ----------------------------------------------------------------------- +// FUNCIàN QUE INICIA EL MODO GRµFICO +// ----------------------------------------------------------------------- + + +void modo_grafico(){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", + grapherrormsg(errorcode)); + printf("Pulse cualquier tecla1 para finalizar..."); + getch(); + exit(1); + } +} + +// ----------------------------------------------------------------------- +// FUNCION MENU +// ----------------------------------------------------------------------- +void menu(int estoy_en, int select_actual) { + + //-------------------- CABECERA DE LA PANTALLA ----------------------- + if (*p_refresco) // tomamos otro refresco... (ahora una fanta lim¢n). + { + setviewport(0, 0, getmaxx(), getmaxy(), 0); + settextstyle(2, 0, 5); + ventana(1, 1, getmaxx(), getmaxy(), 1, 9, titulo); + boton(5, 30, getmaxx()-5, 80, 3, 0, "", 9); + + setcolor(8); line(5, 90, getmaxx()-5, 90); // dibujamos una doble + setcolor(15); line(5, 91, getmaxx()-5, 91); // l¡nea. + + settextstyle(7,0,6); setcolor (1); // caja central con nuestro + outtextxy(110,23,"Video Club ALFA"); // logo del videoclub. + + setcolor(8); line(5, 134, getmaxx()-5, 134); // dibujamos otra doble + setcolor(15); line(5, 135, getmaxx()-5, 135); // l¡nea. + + localizacion(estoy_en,125,105); // mostramos en una barra donde estamos + + *p_refresco=0; // demasiadas burbujas... + } + //----------------- fin de la cabecera de la pantalla ------------------ + + setviewport(110, 180, 600, 300, 0); // zona de los botones. + + switch (estoy_en) // Mostramos un men£ seg£n donde estemos. + { + case 1: // ------------- MENU PRINCIPAL ------------------------------ + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Gesti¢n de Clientes", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Gesti¢n de Pedidos", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Alquileres", 16); + boton(0, 125, 250, 150, 7, 0, "4.- Devoluciones", 16); + boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16); + break; + + case 11: // ---------------- MENU CLIENTES --------------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Altas de Clientes", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Bajas de Clientes", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Modificaciones", 16); + boton(0, 125, 250, 150, 7, 0, "4.- Listado de clientes", 16); + boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16); + break; + + case 12: // ------------- MENU GESTION DE PEDIDOS --------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Altas de Pel¡culas", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Bajas de Pel¡culas", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Modificaciones", 16); + boton(0, 125, 250, 150, 7, 0, "4.- Listado de datos", 16); + boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16); + break; + + case 13: //------------------ MENU 3: ALQUILERES -------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Altas de Alquiler", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Modificar", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Volver", 16); + break; + + case 14:// ------------------- MENU 4: DEVOLUCIONES ------------------ + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Devoluciones", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Modificaciones", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Volver", 16); + break; + + } //fin del switch-case(estoy_en). + setlinestyle(1,0,2); + switch (select_actual)// Ahora pintamos un recuadro al bot¢n seleccionado. + { + case 1: + rectangle(5,9,245,26); + setlinestyle(0,0,2);rectangle(0,5,250,30); + break; + case 2: + rectangle(5,49,245,66); + setlinestyle(0,0,2);rectangle(0,45,250,70); + break; + case 3: + rectangle(5, 89, 245, 106); + setlinestyle(0,0,2);rectangle(0,85,250,110); + break; + case 4: + rectangle(5, 129, 245, 146); + setlinestyle(0,0,2);rectangle(0,125,250,150); + break; + case 5: + rectangle(5,169, 245, 186); + setlinestyle(0,0,2);rectangle(0,165,250,190); + break; + + } // fin del switch-case(select_actual). + setlinestyle(0,0,0); // volvemos a poner el estilo de l¡nea normal. + +} // fin de la funci¢n men£. + +// ------------------------------------------------------------------------ +// FUNCIàN LOCALIZACIàN +// ------------------------------------------------------------------------ +void localizacion(int estoy_en, int x, int y) { + + settextstyle(2,0,5); + boton(5,100,getmaxx()-225,124,7,1,"Localizaci¢n:",8); + setcolor(1); + switch (estoy_en) { + case 1: + outtextxy(x,y,"Men£ General"); + break; + case 11: + outtextxy(x,y, "Men£ General / Gesti¢n de Clientes"); + break; + case 12: + outtextxy(x,y, "Men£ General / Gesti¢n de Pedidos"); + break; + case 13: + outtextxy(x,y, "Men£ General / Alquileres"); + break; + case 14: + outtextxy(x,y, "Men£ General / Devoluciones"); + break; + } // fin del switch-case +} // fin de la funci¢n. + +// ------------------------------------------------------------------------ +// FUNCIàN RELOJ +// ------------------------------------------------------------------------ + +void reloj (int x, int y) { + setviewport(0,0,getmaxx(),getmaxy(),1); + time_t t; + time(&t); + settextstyle(2,0,5); + boton (x,y,x+210,y+25,7,0,ctime(&t),1); +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE CLIENTES +// ------------------------------------------------------------------------ +void altas_clientes(int n) { + int j=0; + while (j0) j++; + if (j +#include +#include +#include +#include +#include +#include +#include "a:\gui.h" +#include "k:\lib\libre.h" +#include "a:\iconos.h" + +char titulo[80]={"Programa Gesti¢n del VideoClub Alfa. Juan L¢pez Fern ndez"}; + +int estoy_en=1;// Indica el men£ en el que me encuentro. +int select_actual=1; // Indica que opci¢n est  seleccionada actualmente. +int n_op_menu=5; // N£mero de opciones del menu. (default menu1=5) +int refresco=1; // Para el calor... Refresca la pantalla :-). +int codigo_max=0, codigo_maxp=0, codigo_maxa=0; + +int *p_estoy_en=&estoy_en;// -- Punteros a sus respectivas variables. -- +int *p_select_actual=&select_actual; +int *p_n_op_menu=&n_op_menu; +int *p_refresco=&refresco; + +// -------- Definici¢n de los patrones o "templates" --------------------- +struct peliculas { + char titulo[20], tema[10], director[21], duracion[4]; + int codigo, n_alquileres, alq; +}; + +struct clientes{ + char nombre[11], apellidos[21], direccion[21], telefono[11]; + int codigo; +}; + +struct alquileres { + int lista_pelis[5], socios, codigo; + float fecha_dev; +}; +// ---------------- Fin de la definici¢n de los patrones. ----------------- + +struct peliculas pelis[50]; // Declaraci¢n de arrays +struct clientes socios[50]; // de estructuras. +struct alquileres presta[50]; // A nivel global. + + +void modo_grafico(); +void menu(int, int); +void miga(int*, int*); +void localizacion(int, int, int); +void reloj(int, int); + +void altas_clientes(int); +void bajas_clientes(int); +void modificar_clientes(int); +void listar_clientes(int); + +void altas_peliculas(int); +void bajas_peliculas(int); +void modificar_peliculas(int); +void listar_peliculas(int); + +void altas_alquileres(int); +void modificar_alquileres(int); +//void listar_alquileres(int); + +void bajas_alquileres(int); +// *********************************************************************** +// PROGRAMA PRINCIPAL +// *********************************************************************** +void main() { + + modo_grafico(); + //presentacion(); // Me pregunto si llegar‚ a hacerla... ;-). Creo que no. + menu(estoy_en, select_actual); + int tecla1, tecla12, sw=1; + + while(sw==1){ + reloj(423,100); + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (select_actual<=1) + select_actual=1; + else { + select_actual--; + menu(estoy_en, select_actual); + } + break; + case 80: // Flecha abajo + if (select_actual>=n_op_menu) + select_actual=n_op_menu; + else{ + select_actual++; + menu(estoy_en, select_actual); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + miga(p_estoy_en, p_select_actual); + menu(estoy_en, select_actual); + } + else + if (tecla1==27) + if (estoy_en==1) // Se acab¢ la funci¢n... + sw=0; + else // Navegaci¢n descendente por men£s. + + { + *p_estoy_en/=10; + *p_n_op_menu=5; + *p_select_actual=1; + *p_refresco=1; + menu(estoy_en,select_actual); + } + } // fin del while + +// getch(); + closegraph(); +} + +// *********************************************************************** +// --- FUNCIONES DEL PROGRAMA --- +// *********************************************************************** + +// ------------------------------------------------------------------------ +// FUNCIàN MIGA (MIGA DEL ASUNTO) +// (con punteros!, como mola...) +// ------------------------------------------------------------------------ +void miga(int *p_estoy_en,int *p_select_actual) { + + *p_refresco=1; // antes de nada tomemos una coca-cola... ;-) + + switch (*p_estoy_en) // veamos que hay que hacer: + { + case 1: // naveguemos por los men£s: ir a menu 1.x + switch (*p_select_actual) + { + case 1: + *p_estoy_en=11; + *p_select_actual=1; + *p_n_op_menu=5; + break; + case 2: + *p_estoy_en=12; + *p_select_actual=1; + *p_n_op_menu=5; + break; + case 3: + *p_estoy_en=13; + *p_select_actual=1; + *p_n_op_menu=4; + break; + case 4: + *p_estoy_en=14; + *p_select_actual=1; + *p_n_op_menu=3; + break; + case 5: + exit(1); + break; + } // fin del switch-case(select_actual) de navegaci¢n de men£s. + break;//fin del case 1 general. + + case 11: // Estamos en las opciones del menu1. + switch (select_actual) // veamos que hay que hacer. + { + case 1: // ALTAS DE CLIENTES. + altas_clientes(50); + break; + case 2: //BAJAS DE CLIENTES. + bajas_clientes(50); + break; + case 3: //MODIFICAR CLIENTES. + modificar_clientes(50); + break; + case 4: // LISTAR CLIENTES. + listar_clientes(50); + break; + case 5: // VOLVER AL MENU 1. + *p_estoy_en=1; + *p_select_actual=1; + *p_n_op_menu=5; + break; + } + break; + case 12: + switch (select_actual) // veamos que hay que hacer. + { + case 1: // ALTAS DE PELICULAS. + altas_peliculas(50); + break; + case 2: //BAJAS DE PELICULAS. + bajas_peliculas(50); + break; + case 3: //MODIFICAR PELICULAS. + modificar_peliculas(50); + break; + case 4: // LISTAR PELICULAS. + listar_peliculas(50); + break; + case 5: // VOLVER AL MENU 1. + *p_estoy_en=1; + *p_select_actual=1; + *p_n_op_menu=5; + break; + } + break; + case 13: + switch (select_actual) // veamos que hay que hacer. + { + case 1: // ALTAS DE ALQUILERES. + altas_alquileres(50); + break; + case 2: //MODIFICAR ALQUILERES. + //modificar_alquileres(50); + break; + case 3: //LISTAR ALQUILERES. + //listar_alquileres(50); + break; + case 4: // VOLVER AL MENU 1. + *p_estoy_en=1; + *p_select_actual=1; + *p_n_op_menu=5; + break; + } + break; + case 14: + switch (select_actual) // veamos que hay que hacer. + { + case 1: // BAJAS DE ALQUILERES. + //bajas_alquileres(50); + break; + case 2: // VOLVER AL MENU 1. + *p_estoy_en=1; + *p_select_actual=1; + *p_n_op_menu=5; + break; + } + break; + } // fin del switch-case(estoy_en) general (TOCHO). +} // fin de la funci¢n miga + +// ----------------------------------------------------------------------- +// FUNCIàN QUE INICIA EL MODO GRµFICO +// ----------------------------------------------------------------------- + + +void modo_grafico(){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", + grapherrormsg(errorcode)); + printf("Pulse cualquier tecla1 para finalizar..."); + getch(); + exit(1); + } +} + +// ----------------------------------------------------------------------- +// FUNCION MENU +// ----------------------------------------------------------------------- +void menu(int estoy_en, int select_actual) { + + //-------------------- CABECERA DE LA PANTALLA ----------------------- + if (*p_refresco) // tomamos otro refresco... (ahora una fanta lim¢n). + { + setviewport(0, 0, getmaxx(), getmaxy(), 0); + settextstyle(2, 0, 5); + ventana(1, 1, getmaxx(), getmaxy(),titulo,1,9); + boton(5, 30, getmaxx()-5, 80, 0, "", 9, 3); + + setcolor(8); line(5, 90, getmaxx()-5, 90); // dibujamos una doble + setcolor(15); line(5, 91, getmaxx()-5, 91); // l¡nea. + + settextstyle(7,0,6); setcolor (1); // caja central con nuestro + outtextxy(110,23,"Video Club ALFA"); // logo del videoclub. + + setcolor(8); line(5, 134, getmaxx()-5, 134); // dibujamos otra doble + setcolor(15); line(5, 135, getmaxx()-5, 135); // l¡nea. + + localizacion(estoy_en,125,105); // mostramos en una barra donde estamos + + *p_refresco=0; // demasiadas burbujas... + } + //----------------- fin de la cabecera de la pantalla ------------------ + + setviewport(185, 180, 600, 300, 0); // zona de los botones. + + switch (estoy_en) // Mostramos un men£ seg£n donde estemos. + { + case 1: // ------------- MENU PRINCIPAL ------------------------------ + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Gesti¢n de Clientes", 16,7); + boton(0, 45, 250, 70, 0, "2.- Gesti¢n de Pel¡culas", 16,7); + boton(0, 85, 250, 110, 0, "3.- Alquileres", 16,7); + boton(0, 125, 250, 150, 0, "4.- Devoluciones", 16,7); + boton(0, 165, 250, 190, 0, "5.- Salir", 16,7); + break; + + case 11: // ---------------- MENU CLIENTES --------------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Altas de Clientes", 16,7); + boton(0, 45, 250, 70, 0, "2.- Bajas de Clientes", 16,7); + boton(0, 85, 250, 110, 0, "3.- Modificaciones", 16,7); + boton(0, 125, 250, 150, 0, "4.- Listado de clientes", 16,7); + boton(0, 165, 250, 190, 0, "5.- Volver", 16,7); + break; + + case 12: // ------------- MENU GESTION DE PEDIDOS --------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Altas de Pel¡culas", 16,7); + boton(0, 45, 250, 70, 0, "2.- Bajas de Pel¡culas", 16,7); + boton(0, 85, 250, 110, 0, "3.- Modificaciones", 16,7); + boton(0, 125, 250, 150, 0, "4.- Listado de datos", 16,7); + boton(0, 165, 250, 190, 0, "5.- Volver", 16,7); + break; + + case 13: //------------------ MENU 3: ALQUILERES -------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Altas de Alquiler", 16,7); + boton(0, 45, 250, 70, 0, "2.- Modificar", 16,7); + boton(0, 85, 250, 110, 0, "3.- Listar Alquileres", 16,7); + boton(0, 125, 250, 150, 0, "4.- Volver", 16,7); + break; + + case 14:// ------------------- MENU 4: DEVOLUCIONES ------------------ + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Devoluciones", 16,7); + boton(0, 45, 250, 70, 0, "2.- Modificaciones", 16,7); + boton(0, 85, 250, 110, 0, "3.- Volver", 16,7); + break; + + } //fin del switch-case(estoy_en). + setlinestyle(1,0,2); + switch (select_actual)// Ahora pintamos un recuadro al bot¢n seleccionado. + { + case 1: + rectangle(5,9,245,26); + setlinestyle(0,0,2);rectangle(0,5,250,30); + break; + case 2: + rectangle(5,49,245,66); + setlinestyle(0,0,2);rectangle(0,45,250,70); + break; + case 3: + rectangle(5, 89, 245, 106); + setlinestyle(0,0,2);rectangle(0,85,250,110); + break; + case 4: + rectangle(5, 129, 245, 146); + setlinestyle(0,0,2);rectangle(0,125,250,150); + break; + case 5: + rectangle(5,169, 245, 186); + setlinestyle(0,0,2);rectangle(0,165,250,190); + break; + + } // fin del switch-case(select_actual). + setlinestyle(0,0,0); // volvemos a poner el estilo de l¡nea normal. + +} // fin de la funci¢n men£. + +// ------------------------------------------------------------------------ +// FUNCIàN LOCALIZACIàN +// ------------------------------------------------------------------------ +void localizacion(int estoy_en, int x, int y) { + + settextstyle(2,0,5); + boton(5,100,getmaxx()-225,124,1,"Localizaci¢n:",8,7); + setcolor(1); + switch (estoy_en) { + case 1: + outtextxy(x,y,"Men£ General"); + break; + case 11: + outtextxy(x,y, "Men£ General / Gesti¢n de Clientes"); + break; + case 12: + outtextxy(x,y, "Men£ General / Gesti¢n de Pedidos"); + break; + case 13: + outtextxy(x,y, "Men£ General / Alquileres"); + break; + case 14: + outtextxy(x,y, "Men£ General / Devoluciones"); + break; + } // fin del switch-case +} // fin de la funci¢n. + +// ------------------------------------------------------------------------ +// FUNCIàN RELOJ +// ------------------------------------------------------------------------ + +void reloj (int x, int y) { + setviewport(0,0,getmaxx(),getmaxy(),1); + time_t t; + time(&t); + settextstyle(2,0,5); + boton (x,y,x+210,y+25,0,ctime(&t),1,7); +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE CLIENTES +// ------------------------------------------------------------------------ +void altas_clientes(int n) { + int j=0; + while (j0) j++; + if (jcodigo_max){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"El cliente no es socio nuestro."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,192,codigo); + introcad(130,192,codigo,12,0,2,5,7); + } + icon8(10,193); + setcolor(0); + outtextxy(130,72,socios[atoi(codigo)-1].nombre); + outtextxy(130,102,socios[atoi(codigo)-1].apellidos); + outtextxy(130,132,socios[atoi(codigo)-1].direccion); + outtextxy(130,162,socios[atoi(codigo)-1].telefono); + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Confirmar eliminaci¢n",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(30,40,"¨Est  seguro? (s/n)"); + char respuesta=getch(); + while(respuesta!='n' && respuesta!='s') + respuesta=getch(); + if (respuesta=='s') + socios[atoi(codigo)-1].codigo=-1; + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN MODIFICAR CLIENTES +// ------------------------------------------------------------------------ +void modificar_clientes(int n){ + int j=0; + while (jcodigo_max || atoi(codigo)<=0 + || socios[atoi(codigo)-1].codigo==-1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"El cliente no es socio nuestro."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,192,codigo); + introcad(130,192,codigo,12,0,2,5,7); + } + icon8(10,193); + setcolor(0); + outtextxy(130,72,socios[atoi(codigo)-1].nombre); + outtextxy(130,102,socios[atoi(codigo)-1].apellidos); + outtextxy(130,132,socios[atoi(codigo)-1].direccion); + outtextxy(130,162,socios[atoi(codigo)-1].telefono); + setcolor(8); outtextxy(30,190,"C¢digo:"); + setcolor(7);outtextxy(20,30,"Introduzca el C¢digo del Cliente:"); + setcolor(4);outtextxy(20,30,"Elija el Campo a Modificar:"); + setcolor(1); outtextxy(30,70,"Nombre:"); + setcolor(1); outtextxy(30,100,"Apellidos:"); + setcolor(1); outtextxy(30,130,"Direcci¢n:"); + setcolor(1); outtextxy(30,160,"Telefono:"); + + int tecla1, tecla12, sw=1,pos=1,y=73;// pos es el campo (1) + icon9(10,y,4); + while(sw==1){ + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (pos>1){ + pos--;icon9(10,y,7); + y-=30; + icon9(10,y,4); + } + break; + case 80: // Flecha abajo + if (pos<4){ + pos++;icon9(10,y,7); + y+=30; + icon9(10,y,4); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + icon9(10,y,2); + switch(pos){ + case 1: + setcolor(7);outtextxy(130,72,socios[atoi(codigo)-1].nombre); + introcad(130,72,socios[atoi(codigo)-1].nombre,11,16,2,5,7); + break; + case 2: + setcolor(7);outtextxy(130,102,socios[atoi(codigo)-1].apellidos); + introcad(130,102,socios[atoi(codigo)-1].apellidos,21,16,2,5,7); + break; + case 3: + setcolor(7);outtextxy(130,132,socios[atoi(codigo)-1].direccion); + introcad(130,132,socios[atoi(codigo)-1].direccion,21,16,2,5,7); + break; + case 4: + setcolor(7);outtextxy(130,162,socios[atoi(codigo)-1].telefono); + introcad(130,162,socios[atoi(codigo)-1].telefono,11,16,2,5,7); + break; + } + icon9(10,y,4); + } + else + if (tecla1==27) + sw=0; + } // fin del while + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN LISTAR CLIENTES +// ------------------------------------------------------------------------ +void listar_clientes(int n){ + int j=0; + while (j0){ + char cod[6]; + sprintf(cod,"%d",socios[j].codigo); + outtextxy(10,y,cod); + outtextxy(58,y,socios[j].nombre); + outtextxy(152,y,socios[j].apellidos); + outtextxy(332,y,socios[j].direccion); + outtextxy(512,y,socios[j].telefono); + y+=15;con++; + } + } + getch(); + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE PELICULAS +// ------------------------------------------------------------------------ +void altas_peliculas(int n){ + int j=0; + while (j0) j++; + if (jcodigo_maxp){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"La pel¡cula no es conocida."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,222,codigo); + introcad(130,222,codigo,12,0,2,5,7); + } + icon8(10,223); + setcolor(0); + outtextxy(130,72,pelis[atoi(codigo)-1].titulo); + outtextxy(130,102,pelis[atoi(codigo)-1].director); + outtextxy(130,132,pelis[atoi(codigo)-1].duracion); + outtextxy(130,162,pelis[atoi(codigo)-1].tema); + char na[6]={NULL}; + sprintf(na,"%d",pelis[atoi(codigo)-1].n_alquileres); + outtextxy(130,192,na); + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Confirmar eliminaci¢n",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(30,40,"¨Est  seguro? (s/n)"); + char respuesta=getch(); + while(respuesta!='n' && respuesta!='s') + respuesta=getch(); + if (respuesta=='s') + pelis[atoi(codigo)-1].codigo=-1; + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN MODIFICAR PELICULAS +// ------------------------------------------------------------------------ +void modificar_peliculas(int n){ + int j=0; + while (jcodigo_maxp || atoi(codigo)<=0 + || pelis[atoi(codigo)-1].codigo==-1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"La pel¡cula no es conocida."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,222,codigo); + introcad(130,222,codigo,12,0,2,5,7); + } + icon8(10,223); + setcolor(0); + outtextxy(130,72,pelis[atoi(codigo)-1].titulo); + outtextxy(130,102,pelis[atoi(codigo)-1].director); + outtextxy(130,132,pelis[atoi(codigo)-1].duracion); + outtextxy(130,162,pelis[atoi(codigo)-1].tema); + char na[6]={NULL}; + sprintf(na,"%d",pelis[atoi(codigo)-1].n_alquileres); + outtextxy(130,192,na); + + setcolor(8); outtextxy(30,220,"C¢digo:"); + setcolor(7);outtextxy(20,30,"Introduzca el C¢digo de la Pel¡cula:"); + setcolor(4);outtextxy(20,30,"Elija el Campo a Modificar:"); + setcolor(1); outtextxy(30,70,"T¡tulo:"); + setcolor(1); outtextxy(30,100,"Director:"); + setcolor(1); outtextxy(30,130,"Duraci¢n:"); + setcolor(1); outtextxy(30,160,"Tema:"); + + int tecla1, tecla12, sw=1,pos=1,y=73;// pos es el campo (1) + icon9(10,y,4); + while(sw==1){ + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (pos>1){ + pos--;icon9(10,y,7); + y-=30; + icon9(10,y,4); + } + break; + case 80: // Flecha abajo + if (pos<4){ + pos++;icon9(10,y,7); + y+=30; + icon9(10,y,4); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + icon9(10,y,2); + switch(pos){ + case 1: + setcolor(7);outtextxy(130,72,pelis[atoi(codigo)-1].titulo); + introcad(130,72,pelis[atoi(codigo)-1].titulo,20,16,2,5,7); + break; + case 2: + setcolor(7);outtextxy(130,102,pelis[atoi(codigo)-1].director); + introcad(130,102,pelis[atoi(codigo)-1].director,20,16,2,5,7); + break; + case 3: + setcolor(7);outtextxy(130,132,pelis[atoi(codigo)-1].duracion); + introcad(130,132,pelis[atoi(codigo)-1].duracion,4,16,2,5,7); + break; + case 4: + setcolor(7);outtextxy(130,162,pelis[atoi(codigo)-1].tema); + introcad(130,162,pelis[atoi(codigo)-1].tema,11,16,2,5,7); + break; + } + icon9(10,y,4); + } + else + if (tecla1==27) + sw=0; + } // fin del while + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN LISTAR PELICULAS +// ------------------------------------------------------------------------ +void listar_peliculas(int n){ + int j=0; + while (j0){ + char cod[6]; + sprintf(cod,"%d",pelis[j].codigo); + outtextxy(10,y,cod); + outtextxy(58,y,pelis[j].titulo); + outtextxy(220,y,pelis[j].director); + outtextxy(382,y,pelis[j].duracion); + char aux[6]; + sprintf(aux,"%d",pelis[j].n_alquileres); + outtextxy(424,y,aux); + outtextxy(514,y,pelis[j].tema); + y+=15;con++; + } + } + getch(); + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE ALQUILERES +// ------------------------------------------------------------------------ +void altas_alquileres(int n){ + int j=0; + while (j0) j++; + if (jcodigo_max || atoi(codigo)<=0 + || socios[atoi(codigo)-1].codigo==-1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(30,40,"Cliente no v lido. ¨Repetir? (s/n)"); + sound(500);delay(300);nosound(); + a=getch(); + while (a!='s' && a!='n') + a=getch(); + if (a=='s'){ + setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + settextstyle(2,0,5);outtextxy(130,72,codigo); + introcad(130,72,codigo,6,0,2,5,7); + } + else{ + sw2=0; + break; + } + } + presta[j].socios=socios[atoi(codigo)-1].codigo; + if (sw2){ + int con=0,x=130; + while(con<5){ + icon8(10,73); + setcolor(0); + outtextxy(235,72,socios[atoi(codigo)-1].nombre); + outtextxy(320,72,socios[atoi(codigo)-1].apellidos); + icon2(10,103); + introcad(130,102,codigo,6,0,2,5,7); + while(atoi(codigo)>codigo_maxp || atoi(codigo)<=0 + || pelis[atoi(codigo)-1].codigo==-1 + || pelis[atoi(codigo)-1].alq==1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(20,40,"Pelicula no disponible. ¨Repetir? (s/n)"); + sound(500);delay(300);nosound(); + a=getch(); + while (a!='s' && a!='n') + a=getch(); + if (a=='s'){ + setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + settextstyle(2,0,5);outtextxy(130,102,codigo); + introcad(130,102,codigo,6,0,2,5,7); + } + else{ + sw2=0; + break; + } + } + if (sw2){ + icon8(10,103); + setcolor(0); + outtextxy(240,102,pelis[atoi(codigo)-1].titulo); + pelis[atoi(codigo)-1].alq=1; + presta[j].lista_pelis[con]=pelis[atoi(codigo)-1].codigo; + (pelis[atoi(codigo)-1].n_alquileres)++; + } + if (con<5){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Pel¡culas",1,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(20,40,"¨Quiere introducir m s pel¡culas? (s/n)"); + settextstyle(2,0,5); + a=getch(); + while (a!='s' && a!='n') + a=getch(); + if (a=='s'){ + setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + settextstyle(2,0,5);outtextxy(130,102,codigo); + if (sw2){ + outtextxy(240,102,pelis[atoi(codigo)-1].titulo); + setcolor(0); + outtextxy(x,132,codigo); + con++;x+=50; + } + sw2=1; + } + else{ + if (presta[j].lista_pelis[0]==0) + presta[j].codigo=0; + else{ + codigo_maxa=j+1; + } + break; + } + } + } + } + }while(sw); + } + else{ + // imprimir tabla llena + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE ALQUILERES +// ------------------------------------------------------------------------ +void modificar_alquileres(int n){ + int j=0; + while (jcodigo_maxa || atoi(codigo)<=0 + || presta[atoi(codigo)-1].codigo==-1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(20,40,"El alquiler no existe."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(330,102,codigo); + introcad(330,102,codigo,12,0,2,5,7); + } + icon8(230,103); + setcolor(8); outtextxy(250,100,"C¢digo:"); + setcolor(1); outtextxy(30,100,"Pel¡cula 1:"); + setcolor(1); outtextxy(30,130,"Pel¡cula 2:"); + setcolor(1); outtextxy(30,160,"Pel¡cula 3:"); + setcolor(1); outtextxy(30,190,"Pel¡cula 4:"); + setcolor(1); outtextxy(30,220,"Pel¡cula 5:"); + char aux[6]; + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[0]); + setcolor(0);outtextxy(130,102,aux); + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[1]); + outtextxy(130,132,aux); + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[2]); + outtextxy(130,162,aux); + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[3]); + outtextxy(130,192,aux); + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[4]); + outtextxy(130,222,aux); + sprintf(aux,"%d",presta[atoi(codigo)-1].socios); + outtextxy(130,72,aux); + outtextxy(130,235,socios[(presta[atoi(codigo)-1].socios)-1].nombre); + outtextxy(130,320,socios[(presta[atoi(codigo)-1].socios)-1].apellidos); + int tecla1, tecla12, sw=1,pos=1,y=103;// pos es el campo (1) + icon9(10,y,4); + while(sw==1){ + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (pos>1){ + pos--;icon9(10,y,7); + y-=30; + icon9(10,y,4); + } + break; + case 80: // Flecha abajo + if (pos<5){ + pos++;icon9(10,y,7); + y+=30; + icon9(10,y,4); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + icon9(10,y,2); + char aux[6];int sw2=1; + switch(pos){ + case 1: + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[0]); + setcolor(7);outtextxy(130,102,aux); + introcad(130,102,aux,6,16,2,5,7); + while(atoi(codigo)>codigo_maxp || atoi(codigo)<=0 + || pelis[atoi(codigo)-1].codigo==-1 + || pelis[atoi(codigo)-1].alq==1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(20,40,"Pelicula no disponible. ¨Repetir? (s/n)"); + sound(500);delay(300);nosound(); + int a=getch(); + while (a!='s' && a!='n') + a=getch(); + if (a=='s'){ + setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + settextstyle(2,0,5);outtextxy(130,102,codigo); + introcad(130,102,codigo,6,0,2,5,7); + } + else{ + sw2=0; + break; + } + } + if (sw2) + presta[atoi(codigo)-1].lista_pelis[0]=atoi(aux); + else{ + setcolor(0);outtextxy(130,102,aux); + } + break; + case 2: + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[1]); + setcolor(7);outtextxy(130,132,aux); + introcad(130,132,aux,6,16,2,5,7); + presta[atoi(codigo)-1].lista_pelis[1]=atoi(aux); + break; + case 3: + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[2]); + setcolor(7);outtextxy(130,162,aux); + introcad(130,162,aux,4,16,2,5,7); + presta[atoi(codigo)-1].lista_pelis[2]=atoi(aux); + break; + case 4: + sprintf(aux,"%d",presta[atoi(codigo)-1].lista_pelis[3]); + setcolor(7);outtextxy(130,192,aux); + introcad(130,192,aux,11,16,2,5,7); + presta[atoi(codigo)-1].lista_pelis[3]=atoi(aux); + break; + } + icon9(10,y,4); + } + else + if (tecla1==27) + sw=0; + } // fin del while + } +getch(); +} + +void bajas_alquileres(int n){ + int j=0; + while (jcodigo_maxp){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"El alquiler no exuiste."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,192,codigo); + introcad(130,192,codigo,12,0,2,5,7); + } + icon8(10,223); + setcolor(0); + char na[6]={NULL}; + sprintf(na,"%d",pelis[atoi(codigo)-1].n_alquileres); + outtextxy(130,192,na); + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Confirmar eliminaci¢n",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(30,40,"¨Est  seguro? (s/n)"); + char respuesta=getch(); + while(respuesta!='n' && respuesta!='s') + respuesta=getch(); + if (respuesta=='s') + pelis[atoi(codigo)-1].codigo=-1; + } +} \ No newline at end of file diff --git a/CPP/VIDEO2.CPP b/CPP/VIDEO2.CPP new file mode 100644 index 0000000..1f0f6c3 --- /dev/null +++ b/CPP/VIDEO2.CPP @@ -0,0 +1,308 @@ +#include +#include +#include +#include +#include +#include +#include "d:\progs_c\lib\gui.h" + +char titulo[80]={"Programa Gesti¢n del VideoClub Alfa. Juan L¢pez Fern ndez"}; + +int estoy_en=1;// Indica el men£ en el que me encuentro. +int select_actual=1; // Indica que opci¢n est  seleccionada actualmente. +int n_op_menu=5; // N£mero de opciones del menu. (default menu1=5) +int refresco=1; // Para el calor... Refresca la pantalla :-). + +int *p_estoy_en=&estoy_en;// -- Punteros a sus respectivas variables. -- +int *p_select_actual=&select_actual; +int *p_n_op_menu=&n_op_menu; +int *p_refresco=&refresco; + +struct peliculas { + char titulo[20]; + char tema[10]; + int duracion; + int alquileres; +}; + +struct clientes { + int codigo; + char nombre[25]; +}; + +struct alquileres { + struct peliculas lista_pelis[5]; + struct clientes socio; + float fecha_dev; + char finalizado; +}; + + +void modo_grafico(); +void menu(int, int); +void miga(int*, int*); +void localizacion(int, int, int); +void reloj(int, int); + +// *********************************************************************** +// PROGRAMA PRINCIPAL +// *********************************************************************** +void main() { + modo_grafico(); + //presentacion(); // Me pregunto si llegar‚ a hacerla... ;-). + menu(estoy_en, select_actual); + int tecla1, tecla12, sw=1; + + while(sw==1){ + reloj(423,100); + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (select_actual<=1) + select_actual=1; + else { + select_actual--; + menu(estoy_en, select_actual); + } + break; + case 80: // Flecha abajo + if (select_actual>=n_op_menu) + select_actual=n_op_menu; + else{ + select_actual++; + menu(estoy_en, select_actual); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + miga(p_estoy_en, p_select_actual); + menu(estoy_en, select_actual); + } + else + if (tecla1==27) + if (estoy_en==1) // Se acab¢ la funci¢n... + sw=0; + else // Navegaci¢n descendente por men£s. + + { + *p_estoy_en/=10; + *p_n_op_menu=5; + *p_select_actual=1; + *p_refresco=1; + menu(estoy_en,select_actual); + } + } // fin del while + +// getch(); + closegraph(); +} + +// *********************************************************************** +// --- FUNCIONES DEL PROGRAMA --- +// *********************************************************************** + +// ------------------------------------------------------------------------ +// FUNCIàN MIGA (MIGA DEL ASUNTO) +// (con punteros!, como mola...) +// ------------------------------------------------------------------------ +void miga(int *p_estoy_en,int *p_select_actual) { + + *p_refresco=1; // antes de nada tomemos una coca-cola... ;-) + + switch (*p_estoy_en) // veamos que hay que hacer: + { + case 1: // naveguemos por los men£s: ir a menu 1.x + switch (*p_select_actual) + { + case 1: + *p_estoy_en=11; + *p_select_actual=1; + *p_n_op_menu=5; + break; + case 2: + *p_estoy_en=12; + *p_select_actual=1; + *p_n_op_menu=5; + break; + case 3: + *p_estoy_en=13; + *p_select_actual=1; + *p_n_op_menu=3; + break; + case 4: + *p_estoy_en=14; + *p_select_actual=1; + *p_n_op_menu=3; + break; + } // fin del switch-case de navegaci¢n de men£s. + break;//fin del case 1 general. + + } // fin del switch-case general. +} // fin de la funci¢n miga + +// ----------------------------------------------------------------------- +// FUNCIàN QUE INICIA EL MODO GRµFICO +// ----------------------------------------------------------------------- + + +void modo_grafico(){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "d:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", + grapherrormsg(errorcode)); + printf("Pulse cualquier tecla1 para finalizar..."); + getch(); + exit(1); + } +} + +// ----------------------------------------------------------------------- +// FUNCION MENU +// ----------------------------------------------------------------------- +void menu(int estoy_en, int select_actual) { + + //-------------------- CABECERA DE LA PANTALLA ----------------------- + if (*p_refresco) // tomamos otro refresco... (ahora una fanta lim¢n). + { + setviewport(0, 0, getmaxx(), getmaxy(), 0); + settextstyle(2, 0, 5); + ventana(1, 1, getmaxx(), getmaxy(), 1, 9, titulo); + boton(5, 30, getmaxx()-5, 80, 3, 0, "", 9); + + setcolor(8); line(5, 90, getmaxx()-5, 90); // dibujamos una doble + setcolor(15); line(5, 91, getmaxx()-5, 91); // l¡nea. + + settextstyle(7,0,6); setcolor (1); // caja central con nuestro + outtextxy(110,23,"Video Club ALFA"); // logo del videoclub. + + setcolor(8); line(5, 134, getmaxx()-5, 134); // dibujamos otra doble + setcolor(15); line(5, 135, getmaxx()-5, 135); // l¡nea. + + localizacion(estoy_en,125,105); // mostramos en una barra donde estamos + + *p_refresco=0; // demasiadas burbujas... + } + //----------------- fin de la cabecera de la pantalla ------------------ + + setviewport(110, 180, 600, 300, 0); // zona de los botones. + + switch (estoy_en) // Mostramos un men£ seg£n donde estemos. + { + case 1: // ------------- MENU PRINCIPAL ------------------------------ + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Gesti¢n de Clientes", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Gesti¢n de Pedidos", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Alquileres", 16); + boton(0, 125, 250, 150, 7, 0, "4.- Devoluciones", 16); + boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16); + break; + + case 11: // ---------------- MENU CLIENTES --------------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Altas de Clientes", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Bajas de Clientes", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Modificaciones", 16); + boton(0, 125, 250, 150, 7, 0, "4.- Listado de clientes", 16); + boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16); + break; + + case 12: // ------------- MENU GESTION DE PEDIDOS --------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Altas de Pel¡culas", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Bajas de Pel¡culas", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Modificaciones", 16); + boton(0, 125, 250, 150, 7, 0, "4.- Listado de datos", 16); + boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16); + break; + + case 13: //------------------ MENU 3: ALQUILERES -------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Altas de Alquiler", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Modificar", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Volver", 16); + break; + + case 14:// ------------------- MENU 4: DEVOLUCIONES ------------------ + settextstyle(2,0,6); + boton(0, 5, 250, 30, 7, 0, "1.- Devoluciones", 16); + boton(0, 45, 250, 70, 7, 0, "2.- Modificaciones", 16); + boton(0, 85, 250, 110, 7, 0, "3.- Volver", 16); + break; + + } //fin del switch-case(estoy_en). + setlinestyle(3,0,2); + switch (select_actual)// Ahora pintamos un recuadro al bot¢n seleccionado. + { + case 1: + rectangle(5,9,245,26); + setlinestyle(0,0,2);rectangle(0,5,250,30); + break; + case 2: + rectangle(5,49,245,66); + setlinestyle(0,0,2);rectangle(0,45,250,70); + break; + case 3: + rectangle(5, 89, 245, 106); + setlinestyle(0,0,2);rectangle(0,85,250,110); + break; + case 4: + rectangle(5, 129, 245, 146); + setlinestyle(0,0,2);rectangle(0,125,250,150); + break; + case 5: + rectangle(5,169, 245, 186); + setlinestyle(0,0,2);rectangle(0,165,250,190); + break; + + } // fin del switch-case(select_actual). + setlinestyle(0,0,0); // volvemos a poner el estilo de l¡nea normal. + +} // fin de la funci¢n men£. + +// ------------------------------------------------------------------------ +// FUNCIàN LOCALIZACIàN +// ------------------------------------------------------------------------ +void localizacion(int estoy_en, int x, int y) { + + settextstyle(2,0,5); + boton(5,100,getmaxx()-225,124,7,1,"Localizaci¢n:",8); + setcolor(1); + switch (estoy_en) { + case 1: + outtextxy(x,y,"Men£ General"); + break; + case 11: + outtextxy(x,y, "Men£ General / Gesti¢n de Clientes"); + break; + case 12: + outtextxy(x,y, "Men£ General / Gesti¢n de Pedidos"); + break; + case 13: + outtextxy(x,y, "Men£ General / Alquileres"); + break; + case 14: + outtextxy(x,y, "Men£ General / Devoluciones"); + break; + } // fin del switch-case +} // fin de la funci¢n. + +// ------------------------------------------------------------------------ +// FUNCIàN RELOJ +// ------------------------------------------------------------------------ + +void reloj (int x, int y) { + setviewport(0,0,getmaxx(),getmaxy(),1); + time_t t; + time(&t); + settextstyle(2,0,5); + boton (x,y,x+210,y+25,7,0,ctime(&t),1); +} \ No newline at end of file diff --git a/CPP/Video Club Alfa.zip b/CPP/Video Club Alfa.zip new file mode 100644 index 0000000..52f52ba Binary files /dev/null and b/CPP/Video Club Alfa.zip differ diff --git a/CPP/WIN.CPP b/CPP/WIN.CPP new file mode 100644 index 0000000..9784e16 --- /dev/null +++ b/CPP/WIN.CPP @@ -0,0 +1,149 @@ +#include +#include +#include +#include +#include + +#define seleccionado color_numero=color_menu=9;settextstyle(7,0,4); +#define no_seleccionado color_numero=3;color_menu=8;settextstyle(8,0,3); + +void ventana(int x1, int y1, int x2, int y2, char titulo[80]); +void boton(int x1, int y1, int x2, int y2,int, char titulo[80]); +void main(){ + + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "d:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", + grapherrormsg(errorcode)); + printf("Pulse cualquier tecla1 para finalizar..."); + getch(); + exit(1); + } + + int midx, midy, i; + midx = getmaxx() / 2; + midy = getmaxy() / 2; + + /* loop through the fill patterns */ +// for (i=0; i<12; i++) + // { + /* set the fill style */ + setfillstyle(1,1);bar(1,1,getmaxx(),getmaxy()); + + setcolor(8); + bar3d(midx-153, midy-148, midx+153, midy+153, 0, 1); + + setcolor(7); + bar3d(midx-152, midy-147, midx+152, midy+152, 0, 1); + + setcolor(16); + bar3d(midx-151, midy-146, midx+151, midy+151, 0, 1); + setfillstyle(1,9); + bar3d(midx-150, midy-145, midx+150, midy+150, 0, 1); + + setfillstyle(1, 1); + bar3d(midx-150, midy-145, midx+150, midy-120, 0, 1); + + settextstyle(2,0,5); + setcolor(15);outtextxy(midx-140,midy-140,"Ooohh.. It`s Fun !!"); + + getch(); + setfillstyle(1,1);bar(1,1,getmaxx(),getmaxy()); + ventana(midx-150,midy-150,midx+150,midy+150,"Microsoft Word _OX"); + + boton(midx-15,midy-15,midx+60,midy+10,0,"Acepta?"); +// } + getch(); + boton(midx-15,midy-15,midx+60,midy+10,1,"Acepta?");delay(305); + int o=1; + for ( o; o<200;o+=5){ + + ventana(midx-o,midy-o,midx+o,midy+o,"Se Sale..."); + // setfillstyle(1,1);bar(midx-o,midy-o,midx+o,midy+o); + } + ventana(midx-o,midy-o,midx+o,midy+o,"Se Sale..."); + getch(); + +/* int x1=midx-o+3, y1=midy-o+3, x2=midx+o-4, y2=midy-o+20; + bar(x1,y1,x2,y2); + for (int k=0; y1(x1+10);k+=10){ + bar(x1,y1+k,x2,y2+20); + + } */ + getch(); + closegraph(); +} + + +void ventana(int x1, int y1, int x2, int y2,char titulo[]){ + // ventana normal ----------------------------------------------- + + setcolor(7); rectangle(x1,y1,x2,y2); // cuadro gris claro + + setcolor(16); + + line(x1,y2,x2,y2); // linea negra -- abajo + line(x2,y2,x2,y1); // linea negra | derecha + + + setcolor(15); rectangle(x1+1,y1+1,x2-1,y2-1); //cuadro blanco dentro + + setcolor(8); + + line(x1+1,y2-1,x2-1,y2-1); // gris -- abajo + line(x2-1,y1+1,x2-1,y2-1); // gris | derecha + + setfillstyle(1,7); + bar(x1+2,y1+2,x2-2,y2-2);// interior gris de la ventana + + setfillstyle(1,1); + bar(x1+3,y1+3,x2-4,y1+20);// fondo azul del titulo + + setcolor(15); + outtextxy(x1+10,y1+4,titulo); + //-------------------------------------------------------------- + + +} + + +// -------------------------------------------------------------------- +// FUNCIàN BOTON +// -------------------------------------------------------------------- + +void boton(int x1,int y1, int x2,int y2,int pulsado,char titulo[]) { + + setcolor(7); rectangle(x1,y1,x2,y2); // cuadro gris claro + + if (pulsado) + { + setcolor(16); + line(x1, y1, x2, y1); // linea negra -- arriba + line(x1, y2, x1, y1); // linea negra | izquierda + + setcolor(15); + rectangle(x1+1,y1+1,x2-1,y2-1); //cuadro blanco dentro + + setcolor(8); + line(x1+1, y1+1, x2-1, y1+1); // gris -- arriba + line(x1+1, y1+1, x1+1, y2-1); // gris | izquierda + } + else { + setcolor(16); + line(x1, y2, x2, y2); // linea negra -- abajo + line(x2, y2, x2, y1); // linea negra | derecha + + setcolor(15); + rectangle(x1+1, y1+1, x2-1, y2-1); //cuadro blanco dentro + + setcolor(8); + line(x1+1, y2-1, x2-1, y2-1); // gris -- abajo + line(x2-1, y1+1, x2-1, y2-1); // gris | derecha + } + setfillstyle(1,7); + bar(x1+2, y1+2, x2-2, y2-2);// interior gris de la ventana + outtextxy(x1+10,y1+4,titulo); + +} // FIN DE LA FUNCIàN ---------------------------------------------------- \ No newline at end of file diff --git a/CPP/super/ACTPROVE.OBJ b/CPP/super/ACTPROVE.OBJ new file mode 100644 index 0000000..0862435 Binary files /dev/null and b/CPP/super/ACTPROVE.OBJ differ diff --git a/CPP/super/VIDEOFI.CPP b/CPP/super/VIDEOFI.CPP new file mode 100644 index 0000000..c2d0cc9 --- /dev/null +++ b/CPP/super/VIDEOFI.CPP @@ -0,0 +1,1461 @@ +#include +#include +#include +#include +#include +#include +#include +#include "a:\gui.h" +#include "a:\libre.h" +#include "a:\iconos.h" + +char titulo[80]={"Programa Gesti¢n del VideoClub Alfa. PROSOFT, Software"}; +char *hora=NULL; + +int estoy_en=1;// Indica el men£ en el que me encuentro. +int select_actual=1; // Indica que opci¢n est  seleccionada actualmente. +int n_op_menu=5; // N£mero de opciones del menu. (default menu1=5) +int refresco=1; // Para el calor... Refresca la pantalla :-). +int codigo_maxp=0, codigo_maxa=0; + +int *p_estoy_en=&estoy_en;// -- Punteros a sus respectivas variables. -- +int *p_select_actual=&select_actual; +int *p_n_op_menu=&n_op_menu; +int *p_refresco=&refresco; +FILE *cliente,*clientaux,*fcodigo; + +// -------- Definici¢n de los patrones o "templates" --------------------- +struct peliculas { + char titulo[20], tema[10], director[21], duracion[4]; + int codigo, n_alquileres, alq; +}; + +struct clientes{ + int codigo; + char nombre[11], apellidos[21], direccion[21], telefono[11]; +}; + +struct alquileres { + int lista_pelis[5], socios, codigo; + float fecha_dev; +}; +// ---------------- Fin de la definici¢n de los patrones. ----------------- + +struct peliculas pelis; // Declaraci¢n de arrays +struct clientes socios; // de estructuras. +struct alquileres presta; // A nivel global. + +void modo_grafico(); +void menu(int, int); +void miga(int*, int*); +void localizacion(int, int, int); +void reloj(int, int); + +void altas_clientes(); +void bajas_clientes(); +void modificar_clientes(); +void listar_clientes(); + +void altas_peliculas(); +void bajas_peliculas(); +void modificar_peliculas(); +void listar_peliculas(); + +void altas_alquileres(); +void modificar_alquileres(); +//void listar_alquileres(int); + +void bajas_alquileres(); +void limpiar3(); +// *********************************************************************** +// PROGRAMA PRINCIPAL +// *********************************************************************** +void main() { + + modo_grafico(); + //presentacion(); // Me pregunto si llegar‚ a hacerla... ;-). Creo que no. + menu(estoy_en, select_actual); + int tecla1, tecla12, sw=1; + while(sw==1){ + + reloj(423,100); + //fflush(stdin); + tecla1=tecla12=9999; + if (kbhit()) + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (select_actual<=1) + select_actual=1; + else { + select_actual--; + menu(estoy_en, select_actual); + } + break; + case 80: // Flecha abajo + if (select_actual>=n_op_menu) + select_actual=n_op_menu; + else{ + select_actual++; + menu(estoy_en, select_actual); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + miga(p_estoy_en, p_select_actual); + menu(estoy_en, select_actual); + } + else + if (tecla1==27) + if (estoy_en==1) // Se acab¢ la funci¢n... + sw=0; + else // Navegaci¢n descendente por men£s. + + { + *p_estoy_en/=10; + *p_n_op_menu=5; + *p_select_actual=1; + *p_refresco=1; + menu(estoy_en,select_actual); + } + } // fin del while + +// getch(); + closegraph(); +} + +// *********************************************************************** +// --- FUNCIONES DEL PROGRAMA --- +// *********************************************************************** + +// ------------------------------------------------------------------------ +// FUNCIàN MIGA (MIGA DEL ASUNTO) +// (con punteros!, como mola...) +// ------------------------------------------------------------------------ +void miga(int *p_estoy_en,int *p_select_actual) { + + *p_refresco=1; // antes de nada tomemos una coca-cola... ;-) + + switch (*p_estoy_en) // veamos que hay que hacer: + { + case 1: // naveguemos por los men£s: ir a menu 1.x + switch (*p_select_actual) + { + case 1: + *p_estoy_en=11; + *p_select_actual=1; + *p_n_op_menu=5; + break; + case 2: + *p_estoy_en=12; + *p_select_actual=1; + *p_n_op_menu=5; + break; + case 3: + *p_estoy_en=13; + *p_select_actual=1; + *p_n_op_menu=4; + break; + case 4: + *p_estoy_en=14; + *p_select_actual=1; + *p_n_op_menu=3; + break; + case 5: + exit(1); + break; + } // fin del switch-case(select_actual) de navegaci¢n de men£s. + break;//fin del case 1 general. + + case 11: // Estamos en las opciones del menu1. + switch (select_actual) // veamos que hay que hacer. + { + case 1: // ALTAS DE CLIENTES. + altas_clientes(); + break; + case 2: //BAJAS DE CLIENTES. + bajas_clientes(); + break; + case 3: //MODIFICAR CLIENTES. + modificar_clientes(); + break; + case 4: // LISTAR CLIENTES. + //listar_clientes(); + break; + case 5: // VOLVER AL MENU 1. + *p_estoy_en=1; + *p_select_actual=1; + *p_n_op_menu=5; + break; + } + break; + case 12: + switch (select_actual) // veamos que hay que hacer. + { + case 1: // ALTAS DE PELICULAS. + //altas_peliculas(); + break; + case 2: //BAJAS DE PELICULAS. + //bajas_peliculas(); + break; + case 3: //MODIFICAR PELICULAS. + //modificar_peliculas(); + break; + case 4: // LISTAR PELICULAS. + //listar_peliculas(); + break; + case 5: // VOLVER AL MENU 1. + *p_estoy_en=1; + *p_select_actual=1; + *p_n_op_menu=5; + break; + } + break; + case 13: + switch (select_actual) // veamos que hay que hacer. + { + case 1: // ALTAS DE ALQUILERES. + //altas_alquileres(); + break; + case 2: //MODIFICAR ALQUILERES. + //modificar_alquileres(50); + break; + case 3: //LISTAR ALQUILERES. + //listar_alquileres(50); + break; + case 4: // VOLVER AL MENU 1. + *p_estoy_en=1; + *p_select_actual=1; + *p_n_op_menu=5; + break; + } + break; + case 14: + switch (select_actual) // veamos que hay que hacer. + { + case 1: // BAJAS DE ALQUILERES. + //bajas_alquileres(50); + break; + case 2: // VOLVER AL MENU 1. + *p_estoy_en=1; + *p_select_actual=1; + *p_n_op_menu=5; + break; + } + break; + } // fin del switch-case(estoy_en) general (TOCHO). +} // fin de la funci¢n miga + +// ----------------------------------------------------------------------- +// FUNCIàN QUE INICIA EL MODO GRµFICO +// ----------------------------------------------------------------------- + + +void modo_grafico(){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); + errorcode = graphresult(); + if (errorcode != grOk){ + printf("Error al iniciar el modo gr fico: %s\n", + grapherrormsg(errorcode)); + printf("Pulse cualquier tecla para finalizar..."); + getch(); + exit(1); + } +} + +// ----------------------------------------------------------------------- +// FUNCION MENU +// ----------------------------------------------------------------------- +void menu(int estoy_en, int select_actual) { + + //-------------------- CABECERA DE LA PANTALLA ----------------------- + if (*p_refresco) // tomamos otro refresco... (ahora una fanta lim¢n). + { + setviewport(0, 0, getmaxx(), getmaxy(), 0); + settextstyle(2, 0, 5); + ventana(1, 1, getmaxx(), getmaxy(),titulo,1,9); + boton(5, 30, getmaxx()-5, 80, 0, "", 9, 3); + boton (423,100,633,125,0,"",1,7);// para el reloj + setcolor(8); line(5, 90, getmaxx()-5, 90); // dibujamos una doble + setcolor(15); line(5, 91, getmaxx()-5, 91); // l¡nea. + + settextstyle(7,0,6); setcolor (1); // caja central con nuestro + outtextxy(110,23,"Video Club ALFA"); // logo del videoclub. + + setcolor(8); line(5, 134, getmaxx()-5, 134); // dibujamos otra doble + setcolor(15); line(5, 135, getmaxx()-5, 135); // l¡nea. + + localizacion(estoy_en,125,105); // mostramos en una barra donde estamos + + *p_refresco=0; // demasiadas burbujas... + } + //----------------- fin de la cabecera de la pantalla ------------------ + + setviewport(185, 180, 600, 300, 0); // zona de los botones. + + switch (estoy_en) // Mostramos un men£ seg£n donde estemos. + { + case 1: // ------------- MENU PRINCIPAL ------------------------------ + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Gesti¢n de Clientes", 16,7); + boton(0, 45, 250, 70, 0, "2.- Gesti¢n de Pel¡culas", 16,7); + boton(0, 85, 250, 110, 0, "3.- Alquileres", 16,7); + boton(0, 125, 250, 150, 0, "4.- Devoluciones", 16,7); + boton(0, 165, 250, 190, 0, "5.- Salir", 16,7); + break; + + case 11: // ---------------- MENU CLIENTES --------------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Altas de Clientes", 16,7); + boton(0, 45, 250, 70, 0, "2.- Bajas de Clientes", 16,7); + boton(0, 85, 250, 110, 0, "3.- Modificaciones", 16,7); + boton(0, 125, 250, 150, 0, "4.- Listado de clientes", 16,7); + boton(0, 165, 250, 190, 0, "5.- Volver", 16,7); + break; + + case 12: // ------------- MENU GESTION DE PEDIDOS --------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Altas de Pel¡culas", 16,7); + boton(0, 45, 250, 70, 0, "2.- Bajas de Pel¡culas", 16,7); + boton(0, 85, 250, 110, 0, "3.- Modificaciones", 16,7); + boton(0, 125, 250, 150, 0, "4.- Listado de datos", 16,7); + boton(0, 165, 250, 190, 0, "5.- Volver", 16,7); + break; + + case 13: //------------------ MENU 3: ALQUILERES -------------------- + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Altas de Alquiler", 16,7); + boton(0, 45, 250, 70, 0, "2.- Modificar", 16,7); + boton(0, 85, 250, 110, 0, "3.- Listar Alquileres", 16,7); + boton(0, 125, 250, 150, 0, "4.- Volver", 16,7); + break; + + case 14:// ------------------- MENU 4: DEVOLUCIONES ------------------ + settextstyle(2,0,6); + boton(0, 5, 250, 30, 0, "1.- Devoluciones", 16,7); + boton(0, 45, 250, 70, 0, "2.- Modificaciones", 16,7); + boton(0, 85, 250, 110, 0, "3.- Volver", 16,7); + break; + + } //fin del switch-case(estoy_en). + setlinestyle(1,0,2); + switch (select_actual)// Ahora pintamos un recuadro al bot¢n seleccionado. + { + case 1: + rectangle(5,9,245,26); + setlinestyle(0,0,2);rectangle(0,5,250,30); + break; + case 2: + rectangle(5,49,245,66); + setlinestyle(0,0,2);rectangle(0,45,250,70); + break; + case 3: + rectangle(5, 89, 245, 106); + setlinestyle(0,0,2);rectangle(0,85,250,110); + break; + case 4: + rectangle(5, 129, 245, 146); + setlinestyle(0,0,2);rectangle(0,125,250,150); + break; + case 5: + rectangle(5,169, 245, 186); + setlinestyle(0,0,2);rectangle(0,165,250,190); + break; + + } // fin del switch-case(select_actual). + setlinestyle(0,0,0); // volvemos a poner el estilo de l¡nea normal. +} // fin de la funci¢n men£. + +// ------------------------------------------------------------------------ +// FUNCIàN LOCALIZACIàN +// ------------------------------------------------------------------------ +void localizacion(int estoy_en, int x, int y) { + + settextstyle(2,0,5); + boton(5,100,getmaxx()-225,124,1,"Localizaci¢n:",8,7); + setcolor(1); + switch (estoy_en) { + case 1: + outtextxy(x,y,"Men£ General"); + break; + case 11: + outtextxy(x,y, "Men£ General / Gesti¢n de Clientes"); + break; + case 12: + outtextxy(x,y, "Men£ General / Gesti¢n de Pedidos"); + break; + case 13: + outtextxy(x,y, "Men£ General / Alquileres"); + break; + case 14: + outtextxy(x,y, "Men£ General / Devoluciones"); + break; + } // fin del switch-case +} // fin de la funci¢n. + +// ------------------------------------------------------------------------ +// FUNCIàN RELOJ +// ------------------------------------------------------------------------ + +void reloj (int x, int y) { + setviewport(0,0,getmaxx(),getmaxy(),1); + + time_t t; + time(&t); + settextstyle(2,0,5); + + char *aux=NULL; + aux=ctime(&t); + if (strcmp (hora,aux) != 0){ + setcolor(7); + outtextxy(x+6,y+6,hora); + strcpy (hora,ctime(&t)); + setcolor(1); + outtextxy(x+6,y+6,ctime(&t)); + } + + +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE CLIENTES +// ------------------------------------------------------------------------ +void altas_clientes() { + int j=0; + socios.codigo=0; + for(int i=0;i<10;i++){ + socios.nombre[i]=NULL; + socios.telefono[i]=NULL; + } + for (i=0;i<20;i++){ + socios.apellidos[i]=NULL; + socios.direccion[i]=NULL; + } + if ((cliente=fopen("k:\\files\\clientes.dat","rb"))==NULL && + (cliente=fopen("k:\\files\\clientes.mov","rb"))==NULL){ + j=1; + fclose(cliente); + } + else{ + fclose(cliente); + clientaux=fopen("k:\\files\\clientes.cdg","a+b"); + fread(&j,2,1,clientaux); + fclose(clientaux); + j++; + } + + if (j<32000){ + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Alta de Clientes",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca los Datos del Cliente:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + + setcolor(1); outtextxy(30,70,"Nombre:"); + setcolor(16); boton(120,70,220,90,1,"",0,0); + setcolor(1); outtextxy(30,100,"Apellidos:"); + setcolor(16); boton(120,100,295,120,1,"",0,0); + setcolor(1); outtextxy(30,130,"Direcci¢n:"); + setcolor(16); boton(120,130,295,150,1,"",0,0); + setcolor(1); outtextxy(30,160,"Telefono:"); + setcolor(16); boton(120,160,220,180,1,"",16,0); + + setcolor(8); outtextxy(30,190,"C¢digo:"); + char aux[11]; + socios.codigo=j;sprintf(aux,"%d",socios.codigo); + setcolor(16); boton(120,190,220,210,1,"",16,0); + outtextxy(130,192,aux); + + icon2(10,73); + introcad(130,72,socios.nombre,10,16,2,5,7); + icon8(10,73);icon2(10,103); + introcad(130,102,socios.apellidos,20,16,2,5,7); + icon8(10,103);icon2(10,133); + introcad(130,132,socios.direccion,20,16,2,5,7); + icon8(10,133);icon2(10,163); + introcad(130,162,socios.telefono,10,16,2,5,7); + icon8(10,163); + ventana(240,160,475,235,"Verificaci¢n de datos",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(270,200,"¨Datos Correctos? (s/n)"); + char respuesta=getch(); + while(respuesta!='n' && respuesta!='s') + respuesta=getch(); + if (respuesta=='s'){ + cliente=fopen("k:\\files\\clientes.mov","a+b"); + fwrite("A",1,1,cliente);// Tipo de movimiento. + fwrite(&(socios.codigo),2,1,cliente); + fwrite(&(socios.nombre),10,1,cliente); + fwrite(&(socios.apellidos),20,1,cliente); + fwrite(&(socios.direccion),20,1,cliente); + fwrite(&(socios.telefono),10,1,cliente); + fclose(cliente); + clientaux=fopen("k:\\files\\clientes.cdg","w+b"); + fwrite(&j,2,1,clientaux); + fclose(clientaux); + } + } + else{ + // imprimir tabla llena + } +} // fin de la funci¢n altas_clientes + +// ------------------------------------------------------------------------ +// FUNCIàN BAJAS DE CLIENTES +// ------------------------------------------------------------------------ +void bajas_clientes(){ + int sw=1; + if ((cliente=fopen("k:\\files\\clientes.dat","r+b"))==NULL){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"No hay clientes !!"); + sound(500);delay(300);nosound();getch(); + } + else{ + char codigo[11]={NULL}; + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Bajas de Clientes",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca el C¢digo del Cliente:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + + setcolor(8); outtextxy(30,70,"Nombre:"); + setcolor(16); boton(120,70,220,90,1,"",0,0); + setcolor(8); outtextxy(30,100,"Apellidos:"); + setcolor(16); boton(120,100,295,120,1,"",0,0); + setcolor(8); outtextxy(30,130,"Direcci¢n:"); + setcolor(16); boton(120,130,295,150,1,"",0,0); + setcolor(8); outtextxy(30,160,"Telefono:"); + setcolor(16); boton(120,160,220,180,1,"",16,0); + + setcolor(1); outtextxy(30,190,"C¢digo:"); + setcolor(16); boton(120,190,220,210,1,"",16,0); + icon2(10,193); + limpiar3(); + introcad(130,192,codigo,11,0,2,5,7); + fseek(cliente,0,0); + while(sw){ + fread(&(socios.codigo),2,1,cliente); + if (socios.codigo==atoi(codigo)) + sw=0; + else{ + fseek(cliente,64,1); + } + if (feof(cliente)) + break; + } + if (sw){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"El cliente no es socio nuestro."); + sound(500);delay(300);nosound(); + getch(); + } + else{ + icon8(10,193); + setcolor(0); + fread(&(socios.nombre),11,1,cliente); + fread(&(socios.apellidos),21,1,cliente); + fread(&(socios.direccion),21,1,cliente); + fread(&(socios.telefono),11,1,cliente); + fclose(cliente); + outtextxy(130,72,socios.nombre); + outtextxy(130,102,socios.apellidos); + outtextxy(130,132,socios.direccion); + outtextxy(130,162,socios.telefono); + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Confirmar eliminaci¢n",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(30,40,"¨Est  seguro? (s/n)"); + char respuesta=getch(); + while(respuesta!='n' && respuesta!='s') + respuesta=getch(); + if (respuesta=='s'){ + cliente=fopen("k:\\files\\clientes.mov","a+b"); + fwrite("B",1,1,cliente);// Tipo de movimiento. + fwrite(&socios,sizeof(socios),1,cliente); + fclose(cliente); + } + } + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN MODIFICAR CLIENTES +// ------------------------------------------------------------------------ +void modificar_clientes(){ +// int j=0; + if ((cliente=fopen("k:\\files\\clientes.dat","r+b"))==NULL){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"No hay clientes !!"); + sound(500);delay(300);nosound();getch(); + } + else{ + if ((fcodigo=fopen("k:\\files\\clientes.cdg","r+b"))==NULL){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"Faltan Archivos !!"); + sound(500);delay(300);nosound();getch(); + } + else{ + char codigo[11]={NULL}; + char codigo_max[11]={NULL}; + fread(codigo_max,2,1,fcodigo); + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Modificaci¢n de Clientes",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca el C¢digo del Cliente:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + + setcolor(8); outtextxy(30,70,"Nombre:"); + setcolor(16); boton(120,70,220,90,1,"",0,0); + setcolor(8); outtextxy(30,100,"Apellidos:"); + setcolor(16); boton(120,100,295,120,1,"",0,0); + setcolor(8); outtextxy(30,130,"Direcci¢n:"); + setcolor(16); boton(120,130,295,150,1,"",0,0); + setcolor(8); outtextxy(30,160,"Telefono:"); + setcolor(16); boton(120,160,220,180,1,"",16,0); + + setcolor(1); outtextxy(30,190,"C¢digo:"); + setcolor(16); boton(120,190,220,210,1,"",16,0); + icon2(10,193); + introcad(130,192,codigo,11,0,2,5,7); + while(atoi(codigo)>atoi(codigo_max) || atoi(codigo)<=0 + || socios.codigo==-1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"El cliente no es socio nuestro."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,192,codigo); + introcad(130,192,codigo,12,0,2,5,7); + } + icon8(10,193); + setcolor(0); + outtextxy(130,72,socios.nombre); + outtextxy(130,102,socios.apellidos); + outtextxy(130,132,socios.direccion); + outtextxy(130,162,socios.telefono); + setcolor(8); outtextxy(30,190,"C¢digo:"); + setcolor(7);outtextxy(20,30,"Introduzca el C¢digo del Cliente:"); + setcolor(4);outtextxy(20,30,"Elija el Campo a Modificar:"); + setcolor(1); outtextxy(30,70,"Nombre:"); + setcolor(1); outtextxy(30,100,"Apellidos:"); + setcolor(1); outtextxy(30,130,"Direcci¢n:"); + setcolor(1); outtextxy(30,160,"Telefono:"); + + int tecla1, tecla12, sw=1,pos=1,y=73;// pos es el campo (1) + icon9(10,y,4); + while(sw==1){ + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (pos>1){ + pos--;icon9(10,y,7); + y-=30; + icon9(10,y,4); + } + break; + case 80: // Flecha abajo + if (pos<4){ + pos++;icon9(10,y,7); + y+=30; + icon9(10,y,4); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + icon9(10,y,2); + switch(pos){ + case 1: + setcolor(7);outtextxy(130,72,socios.nombre); + introcad(130,72,socios.nombre,11,16,2,5,7); + break; + case 2: + setcolor(7);outtextxy(130,102,socios.apellidos); + introcad(130,102,socios.apellidos,21,16,2,5,7); + break; + case 3: + setcolor(7);outtextxy(130,132,socios.direccion); + introcad(130,132,socios.direccion,21,16,2,5,7); + break; + case 4: + setcolor(7);outtextxy(130,162,socios.telefono); + introcad(130,162,socios.telefono,11,16,2,5,7); + break; + } + icon9(10,y,4); + } + else + if (tecla1==27) + sw=0; + } // fin del while + } + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN LISTAR CLIENTES +// ------------------------------------------------------------------------ +void listar_clientes(){ + int j=0; + while (j<1 && socios.codigo==0 || socios.codigo==-1) j++; + if (j==1){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"No hay clientes !!"); + sound(500);delay(300);nosound();getch(); + } + else{ + setviewport(20,160,getmaxx(),getmaxy(),0); + ventana(0,0,600,250,"Listado de Clientes",0,0); + + setcolor(4); + outtextxy(10,30,"COD Nombre Apellidos Direcci¢n Tel‚fono"); + setcolor(8); line (10,50,590,50); + setcolor(15); line (10,51,590,51); + setcolor(0);settextstyle(2,0,5); + j=0;int con=0; + for (int y=60;j<1;j++){ + if(con==12){ + getch(); + con=0;y=60;setcolor(7);setfillstyle(1,7);bar(10,60,590,240); + setcolor(0); + } + if (socios.codigo>0){ + char cod[6]; + sprintf(cod,"%d",socios.codigo); + outtextxy(10,y,cod); + outtextxy(58,y,socios.nombre); + outtextxy(152,y,socios.apellidos); + outtextxy(332,y,socios.direccion); + outtextxy(512,y,socios.telefono); + y+=15;con++; + } + } + getch(); + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE PELICULAS +// ------------------------------------------------------------------------ +void altas_peliculas(){ + int j=0; + while (j<1 && pelis.codigo>0) j++; + if (j<1){ + int sw=0; + do{ + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Alta de Pel¡culas",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca los Datos de la Pel¡cula:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + + setcolor(1); outtextxy(30,70,"T¡tulo:"); + setcolor(16); boton(120,70,290,90,1,"",0,0); + setcolor(1); outtextxy(30,100,"Director:"); + setcolor(16); boton(120,100,290,120,1,"",0,0); + setcolor(1); outtextxy(30,130,"Duraci¢n:"); + setcolor(16); boton(120,130,220,150,1,"",0,0); + setcolor(1);outtextxy(160,132,"minutos"); + setcolor(1); outtextxy(30,160,"Tema:"); + setcolor(16); boton(120,160,220,180,1,"",16,0); + settextstyle(2,0,4); + setcolor(8); outtextxy(30,195,"N§ alquileres:"); + setcolor(16); boton(120,190,220,210,1,"",16,0); + settextstyle(2,0,5); + outtextxy(130,192,"0"); + setcolor(8); outtextxy(30,220,"C¢digo:"); + char aux[11]; + pelis.codigo=j+1;sprintf(aux,"%d",pelis.codigo); + setcolor(16); boton(120,220,220,240,1,"",16,0); + outtextxy(130,222,aux); + + icon2(10,73); + introcad(130,72,pelis.titulo,20,16,2,5,7); + icon8(10,73);icon2(10,103); + introcad(130,102,pelis.director,20,16,2,5,7); + icon8(10,103);icon2(10,133); + introcad(130,132,pelis.duracion,4,16,2,5,7); + icon8(10,133);icon2(10,163); + introcad(130,162,pelis.tema,11,16,2,5,7); + icon8(10,163); + ventana(240,160,475,235,"Verificaci¢n de datos",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(270,200,"¨Datos Correctos? (s/n)"); + char respuesta=getch(); + while(respuesta!='n' && respuesta!='s') + respuesta=getch(); + if (respuesta=='n') + sw=1; + else{ + sw=0; + codigo_maxp=j+1; + } + }while(sw); + } + else{ + // imprimir tabla llena + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN BAJAS DE PELICULAS +// ------------------------------------------------------------------------ +void bajas_peliculas(){ + int j=0; + while (j<1 && pelis.codigo==0 || pelis.codigo==-1) j++; + if (j==1){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"No hay pel¡culas !!"); + sound(500);delay(300);nosound();getch(); + } + else{ + char codigo[11]={NULL}; + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Bajas de Pel¡culas",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca el C¢digo de la Pel¡cula:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + + setcolor(8); outtextxy(30,70,"T¡tulo:"); + setcolor(16); boton(120,70,290,90,1,"",0,0); + setcolor(8); outtextxy(30,100,"Director:"); + setcolor(16); boton(120,100,290,120,1,"",0,0); + setcolor(8); outtextxy(30,130,"Duraci¢n:"); + setcolor(16); boton(120,130,220,150,1,"",0,0); + setcolor(1);outtextxy(160,132,"minutos"); + setcolor(8); outtextxy(30,160,"Tema:"); + setcolor(16); boton(120,160,220,180,1,"",16,0); + settextstyle(2,0,4); + setcolor(8); outtextxy(30,195,"N§ alquileres:"); + setcolor(16); boton(120,190,220,210,1,"",16,0); + settextstyle(2,0,5); + + setcolor(1); outtextxy(30,220,"C¢digo:"); + setcolor(16); boton(120,220,220,240,1,"",16,0); + icon2(10,223); + introcad(130,222,codigo,11,0,2,5,7); + while(atoi(codigo)>codigo_maxp){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"La pel¡cula no es conocida."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,222,codigo); + introcad(130,222,codigo,12,0,2,5,7); + } + icon8(10,223); + setcolor(0); + outtextxy(130,72,pelis.titulo); + outtextxy(130,102,pelis.director); + outtextxy(130,132,pelis.duracion); + outtextxy(130,162,pelis.tema); + char na[6]={NULL}; + sprintf(na,"%d",pelis.n_alquileres); + outtextxy(130,192,na); + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Confirmar eliminaci¢n",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(30,40,"¨Est  seguro? (s/n)"); + char respuesta=getch(); + while(respuesta!='n' && respuesta!='s') + respuesta=getch(); + if (respuesta=='s') + pelis.codigo=-1; + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN MODIFICAR PELICULAS +// ------------------------------------------------------------------------ +void modificar_peliculas(){ + int j=0; + while (j<1 && pelis.codigo==0 || pelis.codigo==-1) j++; + if (j==1){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"No hay pel¡culas !!"); + sound(500);delay(300);nosound();getch(); + } + else{ + char codigo[11]={NULL}; + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Modificaci¢n de Pel¡culas",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca el C¢digo de la Pel¡cula:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + + setcolor(1); outtextxy(30,70,"T¡tulo:"); + setcolor(16); boton(120,70,290,90,1,"",0,0); + setcolor(1); outtextxy(30,100,"Director:"); + setcolor(16); boton(120,100,290,120,1,"",0,0); + setcolor(1); outtextxy(30,130,"Duraci¢n:"); + setcolor(16); boton(120,130,220,150,1,"",0,0); + setcolor(1);outtextxy(160,132,"minutos"); + setcolor(1); outtextxy(30,160,"Tema:"); + setcolor(16); boton(120,160,220,180,1,"",16,0); + settextstyle(2,0,4); + setcolor(8); outtextxy(30,195,"N§ alquileres:"); + setcolor(16); boton(120,190,220,210,1,"",16,0); + settextstyle(2,0,5); + + setcolor(1); outtextxy(30,220,"C¢digo:"); + setcolor(16); boton(120,220,220,240,1,"",16,0); + icon2(10,223); + introcad(130,222,codigo,11,0,2,5,7); + while(atoi(codigo)>codigo_maxp || atoi(codigo)<=0 + || pelis.codigo==-1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"La pel¡cula no es conocida."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,222,codigo); + introcad(130,222,codigo,12,0,2,5,7); + } + icon8(10,223); + setcolor(0); + outtextxy(130,72,pelis.titulo); + outtextxy(130,102,pelis.director); + outtextxy(130,132,pelis.duracion); + outtextxy(130,162,pelis.tema); + char na[6]={NULL}; + sprintf(na,"%d",pelis.n_alquileres); + outtextxy(130,192,na); + + setcolor(8); outtextxy(30,220,"C¢digo:"); + setcolor(7);outtextxy(20,30,"Introduzca el C¢digo de la Pel¡cula:"); + setcolor(4);outtextxy(20,30,"Elija el Campo a Modificar:"); + setcolor(1); outtextxy(30,70,"T¡tulo:"); + setcolor(1); outtextxy(30,100,"Director:"); + setcolor(1); outtextxy(30,130,"Duraci¢n:"); + setcolor(1); outtextxy(30,160,"Tema:"); + + int tecla1, tecla12, sw=1,pos=1,y=73;// pos es el campo (1) + icon9(10,y,4); + while(sw==1){ + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (pos>1){ + pos--;icon9(10,y,7); + y-=30; + icon9(10,y,4); + } + break; + case 80: // Flecha abajo + if (pos<4){ + pos++;icon9(10,y,7); + y+=30; + icon9(10,y,4); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + icon9(10,y,2); + switch(pos){ + case 1: + setcolor(7);outtextxy(130,72,pelis.titulo); + introcad(130,72,pelis.titulo,20,16,2,5,7); + break; + case 2: + setcolor(7);outtextxy(130,102,pelis.director); + introcad(130,102,pelis.director,20,16,2,5,7); + break; + case 3: + setcolor(7);outtextxy(130,132,pelis.duracion); + introcad(130,132,pelis.duracion,4,16,2,5,7); + break; + case 4: + setcolor(7);outtextxy(130,162,pelis.tema); + introcad(130,162,pelis.tema,11,16,2,5,7); + break; + } + icon9(10,y,4); + } + else + if (tecla1==27) + sw=0; + } // fin del while + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN LISTAR PELICULAS +// ------------------------------------------------------------------------ +void listar_peliculas(){ + int j=0; + while (j<1 && pelis.codigo==0 || pelis.codigo==-1) j++; + if (j==1){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"No hay pel¡culas !!"); + sound(500);delay(300);nosound();getch(); + } + else{ + setviewport(20,160,getmaxx(),getmaxy(),0); + ventana(0,0,600,250,"Listado de Pel¡culas",0,0); + + setcolor(4); + outtextxy(10,30,"COD T¡tulo Director Min. Alquileres Tema"); + setcolor(8); line (10,50,590,50); + setcolor(15); line (10,51,590,51); + setcolor(0);settextstyle(2,0,5); + j=0;int con=0; + for (int y=60;j<1;j++){ + if(con==12){ + getch(); + con=0;y=60;setcolor(7);setfillstyle(1,7);bar(10,60,590,240); + setcolor(0); + } + if (pelis.codigo>0){ + char cod[6]; + sprintf(cod,"%d",pelis.codigo); + outtextxy(10,y,cod); + outtextxy(58,y,pelis.titulo); + outtextxy(220,y,pelis.director); + outtextxy(382,y,pelis.duracion); + char aux[6]; + sprintf(aux,"%d",pelis.n_alquileres); + outtextxy(424,y,aux); + outtextxy(514,y,pelis.tema); + y+=15;con++; + } + } + getch(); + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE ALQUILERES +// ------------------------------------------------------------------------ +/*void altas_alquileres(){ + int j=0; + while (j<1 && presta.codigo>0) j++; + if (j<1){ + int sw=0; + do{ + char codigo[6]; + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Alta de Alquileres",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca los Datos del Alquiler:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + settextstyle(2,0,4); + setcolor(1); outtextxy(30,73,"Cod. Cliente:"); + setcolor(16); boton(120,70,220,90,1,"",0,0); + setcolor(16); boton(230,70,480,90,1,"",0,0); + setcolor(1); outtextxy(30,103,"Cod. Pel¡cula:"); + setcolor(16); boton(120,100,220,120,1,"",0,0); + setcolor(16); boton(230,100,400,120,1,"",16,0); + settextstyle(2,0,5); + setcolor(8); outtextxy(30,130,"Pel¡culas:"); + setcolor(16); boton(120,130,380,150,1,"",0,0); + setcolor(8); outtextxy(30,160,"Fecha dev:"); + setcolor(16); boton(120,160,220,180,1,"",0,0); + setcolor(0);outtextxy(130,162,"48 h."); + setcolor(8); outtextxy(30,190,"C¢digo:"); + setcolor(16); boton(120,190,220,210,1,"",0,0); + + char aux[11]; + presta.codigo=j+1;sprintf(aux,"%d",presta.codigo); + setcolor(0);outtextxy(130,192,aux); + icon2(10,73); + introcad(130,72,codigo,6,0,2,5,7); + char a;int sw2=1; + while(atoi(codigo)>codigo_max || atoi(codigo)<=0 + || socios.codigo==-1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(30,40,"Cliente no v lido. ¨Repetir? (s/n)"); + sound(500);delay(300);nosound(); + a=getch(); + while (a!='s' && a!='n') + a=getch(); + if (a=='s'){ + setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + settextstyle(2,0,5);outtextxy(130,72,codigo); + introcad(130,72,codigo,6,0,2,5,7); + } + else{ + sw2=0; + break; + } + } + presta.socios=socios.codigo; + if (sw2){ + int con=0,x=130; + while(con<5){ + icon8(10,73); + setcolor(0); + outtextxy(235,72,socios.nombre); + outtextxy(320,72,socios.apellidos); + icon2(10,103); + introcad(130,102,codigo,6,0,2,5,7); + while(atoi(codigo)>codigo_maxp || atoi(codigo)<=0 + || pelis.codigo==-1 + || pelis.alq==1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(20,40,"Pelicula no disponible. ¨Repetir? (s/n)"); + sound(500);delay(300);nosound(); + a=getch(); + while (a!='s' && a!='n') + a=getch(); + if (a=='s'){ + setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + settextstyle(2,0,5);outtextxy(130,102,codigo); + introcad(130,102,codigo,6,0,2,5,7); + } + else{ + sw2=0; + break; + } + } + if (sw2){ + icon8(10,103); + setcolor(0); + outtextxy(240,102,pelis.titulo); + pelis.alq=1; + presta.lista_pelis[con]=pelis.codigo; + (pelis.n_alquileres)++; + } + if (con<5){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Pel¡culas",1,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(20,40,"¨Quiere introducir m s pel¡culas? (s/n)"); + settextstyle(2,0,5); + a=getch(); + while (a!='s' && a!='n') + a=getch(); + if (a=='s'){ + setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + settextstyle(2,0,5);outtextxy(130,102,codigo); + if (sw2){ + outtextxy(240,102,pelis.titulo); + setcolor(0); + outtextxy(x,132,codigo); + con++;x+=50; + } + sw2=1; + } + else{ + if (presta.lista_pelis[0]==0) + presta.codigo=0; + else{ + codigo_maxa=j+1; + } + break; + } + } + } + } + }while(sw); + } + else{ + // imprimir tabla llena + } +} + +// ------------------------------------------------------------------------ +// FUNCIàN ALTAS DE ALQUILERES +// ------------------------------------------------------------------------ +void modificar_alquileres(){ + int j=0; + while (j<1 && presta.codigo==0 || presta.codigo==-1) j++; + if (j==1){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"No hay alquileres!!"); + sound(500);delay(300);nosound();getch(); + } + else{ + char codigo[11]={NULL}; + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Modificaci¢n de Alquileres",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca el C¢digo del Alquiler:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + + settextstyle(2,0,4); + setcolor(8); outtextxy(30,73,"Cod. Cliente:"); + setcolor(16); boton(120,70,220,90,1,"",0,0); + setcolor(16); boton(230,70,480,90,1,"",0,0); + settextstyle(2,0,5); + setcolor(8); outtextxy(30,100,"Pel¡cula 1:"); + setcolor(16); boton(120,100,220,120,1,"",0,0); + setcolor(1); outtextxy(250,100,"C¢digo:"); + setcolor(16); boton(320,100,420,120,1,"",0,0); + setcolor(8); outtextxy(30,130,"Pel¡cula 2:"); + setcolor(16); boton(120,130,220,150,1,"",0,0); + setcolor(8); outtextxy(30,160,"Pel¡cula 3:"); + setcolor(16); boton(120,160,220,180,1,"",16,0); + setcolor(8); outtextxy(30,190,"Pel¡cula 4:"); + setcolor(16); boton(120,190,220,210,1,"",16,0); + setcolor(8); outtextxy(30,220,"Pel¡cula 5:"); + setcolor(16); boton(120,220,220,240,1,"",16,0); + icon2(230,103); + introcad(330,102,codigo,11,0,2,5,7); + while(atoi(codigo)>codigo_maxa || atoi(codigo)<=0 + || presta.codigo==-1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(20,40,"El alquiler no existe."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(330,102,codigo); + introcad(330,102,codigo,12,0,2,5,7); + } + icon8(230,103); + setcolor(8); outtextxy(250,100,"C¢digo:"); + setcolor(1); outtextxy(30,100,"Pel¡cula 1:"); + setcolor(1); outtextxy(30,130,"Pel¡cula 2:"); + setcolor(1); outtextxy(30,160,"Pel¡cula 3:"); + setcolor(1); outtextxy(30,190,"Pel¡cula 4:"); + setcolor(1); outtextxy(30,220,"Pel¡cula 5:"); + char aux[6]; + sprintf(aux,"%d",presta.lista_pelis[0]); + setcolor(0);outtextxy(130,102,aux); + sprintf(aux,"%d",presta.lista_pelis[1]); + outtextxy(130,132,aux); + sprintf(aux,"%d",presta.lista_pelis[2]); + outtextxy(130,162,aux); + sprintf(aux,"%d",presta.lista_pelis[3]); + outtextxy(130,192,aux); + sprintf(aux,"%d",presta.lista_pelis[4]); + outtextxy(130,222,aux); + sprintf(aux,"%d",presta.socios); + outtextxy(130,72,aux); + outtextxy(130,235,socios.nombre); + outtextxy(130,320,socios.apellidos); + int tecla1, tecla12, sw=1,pos=1,y=103;// pos es el campo (1) + icon9(10,y,4); + while(sw==1){ + tecla1=getch(); + + if(tecla1==0) // leemos tecla especial. + { + tecla12=getch(); + switch(tecla12) { + case 72: // Flecha arriba + if (pos>1){ + pos--;icon9(10,y,7); + y-=30; + icon9(10,y,4); + } + break; + case 80: // Flecha abajo + if (pos<5){ + pos++;icon9(10,y,7); + y+=30; + icon9(10,y,4); + } + break; + } // fin del switch-case + }// fin del if + else + if (tecla1==13) // MIGA DEL ASUNTO + { + icon9(10,y,2); + char aux[6];int sw2=1; + switch(pos){ + case 1: + sprintf(aux,"%d",presta.lista_pelis[0]); + setcolor(7);outtextxy(130,102,aux); + introcad(130,102,aux,6,16,2,5,7); + while(atoi(codigo)>codigo_maxp || atoi(codigo)<=0 + || pelis.codigo==-1 + || pelis.alq==1){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,4); + outtextxy(20,40,"Pelicula no disponible. ¨Repetir? (s/n)"); + sound(500);delay(300);nosound(); + int a=getch(); + while (a!='s' && a!='n') + a=getch(); + if (a=='s'){ + setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + settextstyle(2,0,5);outtextxy(130,102,codigo); + introcad(130,102,codigo,6,0,2,5,7); + } + else{ + sw2=0; + break; + } + } + if (sw2) + presta.lista_pelis[0]=atoi(aux); + else{ + setcolor(0);outtextxy(130,102,aux); + } + break; + case 2: + sprintf(aux,"%d",presta.lista_pelis[1]); + setcolor(7);outtextxy(130,132,aux); + introcad(130,132,aux,6,16,2,5,7); + presta.lista_pelis[1]=atoi(aux); + break; + case 3: + sprintf(aux,"%d",presta.lista_pelis[2]); + setcolor(7);outtextxy(130,162,aux); + introcad(130,162,aux,4,16,2,5,7); + presta.lista_pelis[2]=atoi(aux); + break; + case 4: + sprintf(aux,"%d",presta.lista_pelis[3]); + setcolor(7);outtextxy(130,192,aux); + introcad(130,192,aux,11,16,2,5,7); + presta.lista_pelis[3]=atoi(aux); + break; + } + icon9(10,y,4); + } + else + if (tecla1==27) + sw=0; + } // fin del while + } +getch(); +} + +void bajas_alquileres(){ + int j=0; + while (j<1 && presta.codigo==0 || presta.codigo==-1) j++; + if (j==1){ + setviewport(180,220,getmaxx(),getmaxy(),0); + ventana(20,20,240,100,"Error",4,0); + setcolor(0);settextstyle(2,0,6); + icon10(30,60);outtextxy(60,60,"No hay alquileres!!"); + sound(500);delay(300);nosound();getch(); + } + else{ + char codigo[11]={NULL}; + setviewport(70,160,getmaxx(),getmaxy(),0); + ventana(0,0,500,250,"Bajas de Alquileres",0,0); + + setcolor(4); outtextxy(20,30,"Introduzca el C¢digo del Alquiler:"); + setcolor(8); line (20,50,480,50); + setcolor(15); line (20,51,480,51); + + settextstyle(2,0,4); + setcolor(1); outtextxy(30,73,"Cod. Cliente:"); + setcolor(16); boton(120,70,220,90,1,"",0,0); + setcolor(16); boton(230,70,480,90,1,"",0,0); + setcolor(1); outtextxy(30,103,"Cod. Pel¡cula:"); + setcolor(16); boton(120,100,220,120,1,"",0,0); + setcolor(16); boton(230,100,400,120,1,"",16,0); + settextstyle(2,0,5); + setcolor(8); outtextxy(30,130,"Pel¡culas:"); + setcolor(16); boton(120,130,380,150,1,"",0,0); + setcolor(8); outtextxy(30,160,"Fecha dev:"); + setcolor(16); boton(120,160,220,180,1,"",0,0); + setcolor(0);outtextxy(130,162,"48 h."); + setcolor(8); outtextxy(30,190,"C¢digo:"); + setcolor(16); boton(120,190,220,210,1,"",0,0); + + icon2(10,193); + introcad(130,192,codigo,11,0,2,5,7); + while(atoi(codigo)>codigo_maxp){ + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Error",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(12,40,"El alquiler no exuiste."); + sound(500);delay(300);nosound(); + getch();setviewport(0,0,getmaxx(),getmaxy(),0); + setcolor(7);setfillstyle(1,7);bar(305,318,560,400); + setviewport(70,160,getmaxx(),getmaxy(),0); + outtextxy(130,192,codigo); + introcad(130,192,codigo,12,0,2,5,7); + } + icon8(10,223); + setcolor(0); + char na[6]={NULL}; + sprintf(na,"%d",pelis.n_alquileres); + outtextxy(130,192,na); + setviewport(305,318,560,400,1); + ventana(1,1,250,75,"Confirmar eliminaci¢n",4,0); + setcolor(0);settextstyle(2,0,5); + outtextxy(30,40,"¨Est  seguro? (s/n)"); + char respuesta=getch(); + while(respuesta!='n' && respuesta!='s') + respuesta=getch(); + if (respuesta=='s') + pelis.codigo=-1; + } +} */ +void limpiar3(){ + for (int n=0;n<21;n++){ + socios.apellidos[n]=NULL;socios.direccion[n]=NULL; + } + for (n=0;n<11;n++){ + socios.nombre[n]=NULL;socios.telefono[n]=NULL; + } + socios.codigo=0; +} \ No newline at end of file diff --git a/LIB/DXVIDEO.H b/LIB/DXVIDEO.H new file mode 100644 index 0000000..69b818a --- /dev/null +++ b/LIB/DXVIDEO.H @@ -0,0 +1,45 @@ +// ************************************************************************************************ +// +// Soporte para video Direct X. +// +// ************************************** (c) Pedro Díez López ************************************ + +#ifndef __DIRECTX_SUPPORT__ +#define __DIRECTX_SUPPORT__ + +#include + +class CDXVideo +{ +public: + int hres; // Resolucion horizontal. + int vres; // Resolucion vertical + int bpp; // bpp de la resolucion. + int DimBuffer; // Dimension del buffer. + int ElmBuffer; // Elementos del buffer. + union Buffer // Distintos tipos de resolucion. + { + void *bpp; + BYTE *bpp8; + WORD *bpp16; + DWORD *bpp32; + }pBuffer; + HCURSOR mDDCursorShape; + +private: + LPDIRECTDRAW lpDD; // Puntero a Direct Draw. + LPDIRECTDRAWSURFACE lpDDSView; // Puntero a la superficie. + LPDIRECTDRAWSURFACE lpDDSBack; // Puntero a la 2º superficie. + void *lpDXBuffer;// Puntero al LFB. + DDSURFACEDESC ddsd; // Descriptor de Superficie. + DDSCAPS ddscaps; // Descriptor de capabilities. + HRESULT ddrval; // Resultado de la llamada DD. + + +public: + BOOL Inicio(HWND hwnd,int Ancho,int Alto,int BPP); + void Cursor(HCURSOR nCursor); + void Pinta (); + void Fin(); +}; +#endif \ No newline at end of file diff --git a/LIB/GUI.H b/LIB/GUI.H new file mode 100644 index 0000000..46cf1c3 --- /dev/null +++ b/LIB/GUI.H @@ -0,0 +1,96 @@ +void modo_grafico(char ruta[]){ + int gdriver = DETECT, gmode, errorcode; + initgraph(&gdriver, &gmode, ruta); + errorcode = graphresult(); + if (errorcode != grOk) + { + printf("Error grafico: %s\n", grapherrormsg(errorcode)); + printf("Pulse una tecla para finalizar:"); + getch(); + exit(1); + } + +} + + +// ----------------------------------------------------------------------- +// FUNCIàN VENTANA CON TITULO +// ----------------------------------------------------------------------- + +void ventana(int x1, int y1, int x2, int y2,char titulo[], + int fondo_titulo, int fondo_ventana ) +{ + + setcolor(7); + rectangle(x1, y1, x2, y2); // cuadro gris claro + + setcolor(16); + line(x1, y2, x2, y2); // linea negra -- abajo + line(x2, y2, x2, y1); // linea negra | derecha + + setcolor(15); + rectangle(x1+1, y1+1, x2-1, y2-1); // cuadro blanco dentro + + setcolor(8); + line(x1+1, y2-1, x2-1, y2-1); // gris -- abajo + line(x2-1, y1+1, x2-1, y2-1); // gris | derecha + + int fv= (fondo_ventana) ? fondo_ventana : 7; // color del interior de + setfillstyle(1,fv); // la ventana, por defecto + bar(x1+2, y1+2, x2-2, y2-2); // (0) es el gris. + + int ft= (fondo_titulo) ? fondo_titulo : 1; // color del fondo del + setfillstyle(1,ft); // t¡tulo, por defecto (0) + bar(x1+3, y1+3, x2-4, y1+20); // es azul oscuro. + + setcolor(15); + outtextxy(x1+10, y1+4, titulo); // t¡tulo de la ventana + +} // FIN VENTANA --------------------------------------------------------- + + + +// ----------------------------------------------------------------------- +// FUNCIàN BOTON +// ----------------------------------------------------------------------- + +void boton(int x1,int y1, int x2,int y2, int pulsado, char titulo[], + int color_titulo, int fondo_boton) { + + setcolor(7); rectangle(x1,y1,x2,y2); // cuadro gris claro + + if (pulsado) + { + setcolor(16); + line(x1, y1, x2, y1); // linea negra -- arriba + line(x1, y2, x1, y1); // linea negra | izquierda + + setcolor(15); + rectangle(x1+1,y1+1,x2-1,y2-1); //cuadro blanco dentro + + setcolor(8); + line(x1+1, y1+1, x2-1, y1+1); // gris -- arriba + line(x1+1, y1+1, x1+1, y2-1); // gris | izquierda + } + else { + setcolor(16); + line(x1, y2, x2, y2); // linea negra -- abajo + line(x2, y2, x2, y1); // linea negra | derecha + + setcolor(15); + rectangle(x1+1, y1+1, x2-1, y2-1); //cuadro blanco dentro + + setcolor(8); + line(x1+1, y2-1, x2-1, y2-1); // gris -- abajo + line(x2-1, y1+1, x2-1, y2-1); // gris | derecha + } + int fb= (fondo_boton) ? fondo_boton : 7; // color del interior del + setfillstyle(1,fb); // bot¢n, por defecto (0) + bar(x1+2, y1+2, x2-2, y2-2); // es el gris. + int ct= (color_titulo) ? color_titulo : 15; + setcolor(ct); + // settextstyle(2,0,5); + outtextxy(x1+10,y1+4,titulo); + +} // FIN BOTON ----------------------------------------------------------- + diff --git a/LIB/ICONOS.H b/LIB/ICONOS.H new file mode 100644 index 0000000..51279f8 --- /dev/null +++ b/LIB/ICONOS.H @@ -0,0 +1,108 @@ +// ************************************************************************ +// **************** LIBRERÖA DE ICONOS ******************** +// ************************************************************************ + +// ------------------------------------------------------------------------ +// ---------------- LISTA DE ICONOS -------------------- +// ------------------------------------------------------------------------ +// ÉÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» +// º Nombre º Especificaci¢n º +// ÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon1 º Es una cruz roja de 10x10 pixels. º +// ÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon2 º Es una flecha (->) azul de 10x10 pixels. º +// ÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon3 º Es un circulo con borde negro y pintado de verde de 10x10 º +// º º pixels. º +// ÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon4 º Es un c¡rculo blanco (completo incluido borde) de 10x10 º +// º º pixels. º +// ÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon5 º Es un c¡rculo negro (completo incluido borde) de 10x10 º +// º º pixels. º +// ÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon6 º Es un c¡rculo blanco (completo incluido borde) de 20x20 º +// º º pixels. º +// ÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon7 º Es un c¡rculo negro (completo incluido borde) de 20x20 º +// º º pixels. º +// ºÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon8 º Es una flecha (->) gris (con punta azul) de 10x10 pixels. º +// ºÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º *icon9 º Es una flecha (->) de color c de 10x10 pixels. º +// ºÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +// º icon10 º Es un triangulo amarillo con l¡neas negras y una exclama- º +// º º ci¢n negra dentro. Es de 20x20 pixels. º +// ÈÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +// ****** NOTA: A todos los iconos hay que pasarles la posici¢n X y la Y ** +// ****** A los marcados con * hay que pasarles tambi‚n el color ** + + +void icon1(int x,int y){ + setcolor(4);setlinestyle(0,1,3); + line(x,y,x+10,y+10);line(x+10,y,x,y+10); + setlinestyle(0,1,1); +} + +void icon2(int x,int y){ + setcolor(1);setlinestyle(0,1,3); + line(x,y+5,x+5,y+5);setlinestyle(0,1,1); + line(x+5,y,x+10,y+5);line(x+5,y+10,x+10,y+5);line(x+5,y,x+5,y+10); + setfillstyle(1,1);floodfill(x+6,y+6,1); + setlinestyle(0,1,1); +} + +void icon3(int x, int y){ + setlinestyle(0,1,1); + setcolor(0);circle(x+5,y+5,5); + setfillstyle(1,2);floodfill(x+5,y+5,0); +} + +void icon4(int x, int y){ + setlinestyle(0,1,1); + setcolor(15);circle(x,y,5); + setfillstyle(1,15); floodfill(x,y,15); +} + +void icon5(int x, int y){ + setlinestyle(0,1,1); + setcolor(0);circle(x,y,5); + setfillstyle(1,0); floodfill(x,y,0); +} + +void icon6(int x, int y){ + setlinestyle(0,1,1); + setcolor(15);circle(x,y,10); + setfillstyle(1,15); floodfill(x,y,15); +} + +void icon7(int x, int y){ + setlinestyle(0,1,1); + setcolor(0);circle(x,y,10); + setfillstyle(1,0); floodfill(x,y,0); +} + +void icon8(int x,int y){ + setcolor(7);setlinestyle(0,1,3); + line(x,y+5,x+5,y+5);setlinestyle(0,1,1); + line(x+5,y,x+10,y+5);line(x+5,y+10,x+10,y+5);line(x+5,y,x+5,y+10); + setfillstyle(1,1);floodfill(x+6,y+6,1); + setlinestyle(0,1,1); +} + +void icon9(int x,int y,int c){ + setcolor(c);setlinestyle(0,1,3); + line(x,y+5,x+5,y+5);setlinestyle(0,1,1); + line(x+5,y,x+10,y+5);line(x+5,y+10,x+10,y+5);line(x+5,y,x+5,y+10); + setfillstyle(1,c);floodfill(x+6,y+6,c); + setlinestyle(0,1,1); +} + +void icon10(int x,int y){ + setcolor(0);line(x,y+20,x+20,y+20); + line(x,y+20,x+10,y);line(x+20,y+20,x+10,y); + setfillstyle(1,14);floodfill(x+10,y+19,0); + setlinestyle(0,0,2);line(x+10,y+5,x+10,y+13); + setlinestyle(0,0,1);circle(x+10,y+17,1); + setfillstyle(1,0);floodfill(x+10,y+17,0); +} \ No newline at end of file diff --git a/LIB/LIBRE.H b/LIB/LIBRE.H new file mode 100644 index 0000000..70a33f7 --- /dev/null +++ b/LIB/LIBRE.H @@ -0,0 +1,45 @@ +void introcad(int x, int y, char cad[], int a, + int c, int s, int t, int col) { + int i; + for (i=0;i<=a-1;) { + if (i0){ + setcolor(col);settextstyle(s,0,t);outtextxy(x,y,cad); + cad[i-1]=NULL;i-=2; + } + else{ + sound(1000);delay(50);nosound();i--; + } + } + setcolor(c);settextstyle(s,0,t);outtextxy(x,y,cad); + } + else { + if (i==a-1 && cad[i]!=13){ + cad[i]=getche(); + if (cad[i]!=13 && cad[i]!=8){ + sound(1000);delay(50);nosound(); + } + else{ + if (cad[i]==8 && i>=0){ + setcolor(col);settextstyle(s,0,t);outtextxy(x,y,cad); + cad[i-1]=NULL;i--; + setcolor(c);settextstyle(s,0,t);outtextxy(x,y,cad); + } + } + i--; + } + } + if (cad[i]==13 && i>0) + break; + else + if (cad[i]==13 && i==0) + i--; + if (cad[0]!=NULL) + i++; + if (i==-1) + i++; + } + cad[i]=NULL; +} \ No newline at end of file diff --git a/LIB/MILIB.H b/LIB/MILIB.H new file mode 100644 index 0000000..2a030ab --- /dev/null +++ b/LIB/MILIB.H @@ -0,0 +1,31 @@ + +void imprimir_num(int j_resto) { + int numero,base; + int tabla[15]; + clrscr(); + gotoxy(10,12); + printf ("El n£mero %d en base %d es: ",numero,base); + for (;j_resto>=0;j_resto--) { + if (tabla[j_resto]<=9) + printf ("%d",tabla[j_resto]); + else + if (tabla[j_resto]==10) + printf ("A"); + else + if (tabla[j_resto]==11) + printf ("B"); + else + if (tabla[j_resto]==12) + printf ("C"); + else + if (tabla[j_resto]==13) + printf ("D"); + else + if (tabla[j_resto]==14) + printf ("E"); + else + if (tabla[j_resto]==15) + printf ("F"); + + } +} \ No newline at end of file diff --git a/LIB/UTIL.H b/LIB/UTIL.H new file mode 100644 index 0000000..cfe7aa0 --- /dev/null +++ b/LIB/UTIL.H @@ -0,0 +1,16 @@ + +int modo_grafico(char ruta[80]) { + /* request auto detection */ + int gdriver = DETECT, gmode, errorcode; + /* initialize graphics mode */ + initgraph(&gdriver, &gmode, ruta); + /* read result of initialization */ + errorcode = graphresult(); + if (errorcode != grOk) { + printf("Graphics error: %s\n", grapherrormsg(errorcode)); + printf("Press any key to halt:"); + getch(); + exit(1); /* return with error code */ + } +return(0); +} diff --git a/Utilidades de C/3DLIB.ZIP b/Utilidades de C/3DLIB.ZIP new file mode 100644 index 0000000..fabfb9b Binary files /dev/null and b/Utilidades de C/3DLIB.ZIP differ diff --git a/Utilidades de C/BGI256.ZIP b/Utilidades de C/BGI256.ZIP new file mode 100644 index 0000000..576671c Binary files /dev/null and b/Utilidades de C/BGI256.ZIP differ diff --git a/Utilidades de C/BGI28FNT.ZIP b/Utilidades de C/BGI28FNT.ZIP new file mode 100644 index 0000000..8fc579b Binary files /dev/null and b/Utilidades de C/BGI28FNT.ZIP differ diff --git a/Utilidades de C/BGIDRV.ZIP b/Utilidades de C/BGIDRV.ZIP new file mode 100644 index 0000000..98386c6 Binary files /dev/null and b/Utilidades de C/BGIDRV.ZIP differ diff --git a/Utilidades de C/BGIFONT.ZIP b/Utilidades de C/BGIFONT.ZIP new file mode 100644 index 0000000..f87faea Binary files /dev/null and b/Utilidades de C/BGIFONT.ZIP differ diff --git a/Utilidades de C/BMP2IMC.ZIP b/Utilidades de C/BMP2IMC.ZIP new file mode 100644 index 0000000..edd3530 Binary files /dev/null and b/Utilidades de C/BMP2IMC.ZIP differ diff --git a/Utilidades de C/C-WINSRC.ZOO b/Utilidades de C/C-WINSRC.ZOO new file mode 100644 index 0000000..d0de6c1 Binary files /dev/null and b/Utilidades de C/C-WINSRC.ZOO differ diff --git a/Utilidades de C/CXT235.ZIP b/Utilidades de C/CXT235.ZIP new file mode 100644 index 0000000..0db0775 Binary files /dev/null and b/Utilidades de C/CXT235.ZIP differ diff --git a/Utilidades de C/DEVDRV.ZIP b/Utilidades de C/DEVDRV.ZIP new file mode 100644 index 0000000..0d97a00 Binary files /dev/null and b/Utilidades de C/DEVDRV.ZIP differ diff --git a/Utilidades de C/EFONTW11.ZIP b/Utilidades de C/EFONTW11.ZIP new file mode 100644 index 0000000..fd1d9df Binary files /dev/null and b/Utilidades de C/EFONTW11.ZIP differ diff --git a/Utilidades de C/EMIL.ZIP b/Utilidades de C/EMIL.ZIP new file mode 100644 index 0000000..d7e43f6 Binary files /dev/null and b/Utilidades de C/EMIL.ZIP differ diff --git a/Utilidades de C/FLILIB.ZIP b/Utilidades de C/FLILIB.ZIP new file mode 100644 index 0000000..0a94f6c Binary files /dev/null and b/Utilidades de C/FLILIB.ZIP differ diff --git a/Utilidades de C/FLILIB.ZOO b/Utilidades de C/FLILIB.ZOO new file mode 100644 index 0000000..fd41b66 Binary files /dev/null and b/Utilidades de C/FLILIB.ZOO differ diff --git a/Utilidades de C/GTCMOUS1.ZIP b/Utilidades de C/GTCMOUS1.ZIP new file mode 100644 index 0000000..ba598d2 Binary files /dev/null and b/Utilidades de C/GTCMOUS1.ZIP differ diff --git a/Utilidades de C/HCSVGA13.ZIP b/Utilidades de C/HCSVGA13.ZIP new file mode 100644 index 0000000..22fb934 Binary files /dev/null and b/Utilidades de C/HCSVGA13.ZIP differ diff --git a/Utilidades de C/JUAN2.ZIP b/Utilidades de C/JUAN2.ZIP new file mode 100644 index 0000000..a690236 Binary files /dev/null and b/Utilidades de C/JUAN2.ZIP differ diff --git a/Utilidades de C/LP_TC.ZIP b/Utilidades de C/LP_TC.ZIP new file mode 100644 index 0000000..f62f9e7 Binary files /dev/null and b/Utilidades de C/LP_TC.ZIP differ diff --git a/Utilidades de C/MCDT101.ZIP b/Utilidades de C/MCDT101.ZIP new file mode 100644 index 0000000..187243c Binary files /dev/null and b/Utilidades de C/MCDT101.ZIP differ diff --git a/Utilidades de C/MCWINT20.ZIP b/Utilidades de C/MCWINT20.ZIP new file mode 100644 index 0000000..23a6ed5 Binary files /dev/null and b/Utilidades de C/MCWINT20.ZIP differ diff --git a/Utilidades de C/MEMMAN2C.ZIP b/Utilidades de C/MEMMAN2C.ZIP new file mode 100644 index 0000000..428f4cb Binary files /dev/null and b/Utilidades de C/MEMMAN2C.ZIP differ diff --git a/Utilidades de C/MKUTIL20.ZIP b/Utilidades de C/MKUTIL20.ZIP new file mode 100644 index 0000000..eb3293b Binary files /dev/null and b/Utilidades de C/MKUTIL20.ZIP differ diff --git a/Utilidades de C/MMOUSE15.ZIP b/Utilidades de C/MMOUSE15.ZIP new file mode 100644 index 0000000..d36976d Binary files /dev/null and b/Utilidades de C/MMOUSE15.ZIP differ diff --git a/Utilidades de C/MOU105.ZIP b/Utilidades de C/MOU105.ZIP new file mode 100644 index 0000000..d29bc20 Binary files /dev/null and b/Utilidades de C/MOU105.ZIP differ diff --git a/Utilidades de C/MOUCLIB6.ZIP b/Utilidades de C/MOUCLIB6.ZIP new file mode 100644 index 0000000..f642f9a Binary files /dev/null and b/Utilidades de C/MOUCLIB6.ZIP differ diff --git a/Utilidades de C/MOUSH101.ZIP b/Utilidades de C/MOUSH101.ZIP new file mode 100644 index 0000000..a3ef853 Binary files /dev/null and b/Utilidades de C/MOUSH101.ZIP differ diff --git a/Utilidades de C/MTL11.ZIP b/Utilidades de C/MTL11.ZIP new file mode 100644 index 0000000..4d63ea5 Binary files /dev/null and b/Utilidades de C/MTL11.ZIP differ diff --git a/Utilidades de C/NETCL16.ZIP b/Utilidades de C/NETCL16.ZIP new file mode 100644 index 0000000..34af780 Binary files /dev/null and b/Utilidades de C/NETCL16.ZIP differ diff --git a/Utilidades de C/PCSOUND.ZIP b/Utilidades de C/PCSOUND.ZIP new file mode 100644 index 0000000..bc86488 Binary files /dev/null and b/Utilidades de C/PCSOUND.ZIP differ diff --git a/Utilidades de C/POPUPS.ZIP b/Utilidades de C/POPUPS.ZIP new file mode 100644 index 0000000..310b52c Binary files /dev/null and b/Utilidades de C/POPUPS.ZIP differ diff --git a/Utilidades de C/PPORT.ZIP b/Utilidades de C/PPORT.ZIP new file mode 100644 index 0000000..9c56d3f Binary files /dev/null and b/Utilidades de C/PPORT.ZIP differ diff --git a/Utilidades de C/PXDTUT4C.ZIP b/Utilidades de C/PXDTUT4C.ZIP new file mode 100644 index 0000000..8138335 Binary files /dev/null and b/Utilidades de C/PXDTUT4C.ZIP differ diff --git a/Utilidades de C/PXDTUT5C.ZIP b/Utilidades de C/PXDTUT5C.ZIP new file mode 100644 index 0000000..9ae7766 Binary files /dev/null and b/Utilidades de C/PXDTUT5C.ZIP differ diff --git a/Utilidades de C/QLIBGV.ZIP b/Utilidades de C/QLIBGV.ZIP new file mode 100644 index 0000000..a1a9f55 Binary files /dev/null and b/Utilidades de C/QLIBGV.ZIP differ diff --git a/Utilidades de C/SB16SND.ZIP b/Utilidades de C/SB16SND.ZIP new file mode 100644 index 0000000..a42cce2 Binary files /dev/null and b/Utilidades de C/SB16SND.ZIP differ diff --git a/Utilidades de C/SBPROG10.ZIP b/Utilidades de C/SBPROG10.ZIP new file mode 100644 index 0000000..9bf9996 Binary files /dev/null and b/Utilidades de C/SBPROG10.ZIP differ diff --git a/Utilidades de C/SIMPMO24.ZIP b/Utilidades de C/SIMPMO24.ZIP new file mode 100644 index 0000000..fac107d Binary files /dev/null and b/Utilidades de C/SIMPMO24.ZIP differ diff --git a/Utilidades de C/SPRGEN10.ZIP b/Utilidades de C/SPRGEN10.ZIP new file mode 100644 index 0000000..b8912ed Binary files /dev/null and b/Utilidades de C/SPRGEN10.ZIP differ diff --git a/Utilidades de C/SVGABG15.ZIP b/Utilidades de C/SVGABG15.ZIP new file mode 100644 index 0000000..0a1a351 Binary files /dev/null and b/Utilidades de C/SVGABG15.ZIP differ diff --git a/Utilidades de C/SVGABG55.ZIP b/Utilidades de C/SVGABG55.ZIP new file mode 100644 index 0000000..cb84223 Binary files /dev/null and b/Utilidades de C/SVGABG55.ZIP differ diff --git a/Utilidades de C/SW16.ZIP b/Utilidades de C/SW16.ZIP new file mode 100644 index 0000000..14774ef Binary files /dev/null and b/Utilidades de C/SW16.ZIP differ diff --git a/Utilidades de C/TCRES201.ZIP b/Utilidades de C/TCRES201.ZIP new file mode 100644 index 0000000..d2862d9 Binary files /dev/null and b/Utilidades de C/TCRES201.ZIP differ diff --git a/Utilidades de C/TCU_32A.ZIP b/Utilidades de C/TCU_32A.ZIP new file mode 100644 index 0000000..9813896 Binary files /dev/null and b/Utilidades de C/TCU_32A.ZIP differ diff --git a/Utilidades de C/TCWIND16.ZIP b/Utilidades de C/TCWIND16.ZIP new file mode 100644 index 0000000..8ba0ea9 Binary files /dev/null and b/Utilidades de C/TCWIND16.ZIP differ diff --git a/Utilidades de C/TEGLSYS.LIB b/Utilidades de C/TEGLSYS.LIB new file mode 100644 index 0000000..b51f869 Binary files /dev/null and b/Utilidades de C/TEGLSYS.LIB differ diff --git a/Utilidades de C/TGASAVE.ZIP b/Utilidades de C/TGASAVE.ZIP new file mode 100644 index 0000000..fdd5d1a Binary files /dev/null and b/Utilidades de C/TGASAVE.ZIP differ diff --git a/Utilidades de C/TGCBOR20.ZIP b/Utilidades de C/TGCBOR20.ZIP new file mode 100644 index 0000000..08d725f Binary files /dev/null and b/Utilidades de C/TGCBOR20.ZIP differ diff --git a/Utilidades de C/VM10_ARH.ZIP b/Utilidades de C/VM10_ARH.ZIP new file mode 100644 index 0000000..ea123c1 Binary files /dev/null and b/Utilidades de C/VM10_ARH.ZIP differ diff --git a/Utilidades de C/WFLILB24.ZIP b/Utilidades de C/WFLILB24.ZIP new file mode 100644 index 0000000..709a527 Binary files /dev/null and b/Utilidades de C/WFLILB24.ZIP differ diff --git a/Utilidades de C/WINDOWTC.ZIP b/Utilidades de C/WINDOWTC.ZIP new file mode 100644 index 0000000..8e1ffe6 Binary files /dev/null and b/Utilidades de C/WINDOWTC.ZIP differ diff --git a/Utilidades de C/WX168_1.ZIP b/Utilidades de C/WX168_1.ZIP new file mode 100644 index 0000000..bb68d67 Binary files /dev/null and b/Utilidades de C/WX168_1.ZIP differ diff --git a/Utilidades de C/WX168_2.ZIP b/Utilidades de C/WX168_2.ZIP new file mode 100644 index 0000000..af76198 Binary files /dev/null and b/Utilidades de C/WX168_2.ZIP differ diff --git a/Utilidades de C/XYZ_20.ZIP b/Utilidades de C/XYZ_20.ZIP new file mode 100644 index 0000000..f930b7d Binary files /dev/null and b/Utilidades de C/XYZ_20.ZIP differ diff --git a/super/MOUSE.H b/super/MOUSE.H new file mode 100644 index 0000000..5118b7d --- /dev/null +++ b/super/MOUSE.H @@ -0,0 +1,50 @@ +/*************************************************************************** + + Microsoft Mouse Driver v1.0 for BGI graphics modes + + By Erik Kangas + + July 1992 + + v1.5 + + **************************************************************************/ + + +extern "C" { + +int _Cdecl MouseInit(); // Must be called first, sets up env. +void _Cdecl MouseClose(); // Must be called at end, fixes env. +int _Cdecl MHidden(); // Number of layers of hiding +int _Cdecl MActive(); // Is mouse driver present? +void _Cdecl MLeftPressed(); // gets Mspressed for left button +void _Cdecl MRightPressed(); // gets Mspressed for right button +void _Cdecl MLeftReleased(); // gets Msreleased for left button +void _Cdecl MRightReleased(); // gets Msreleased for right button +void _Cdecl MSetXRange(int,int); // set cursor range horiz & vert +void _Cdecl MSetYRange(int,int); // does not range check the values! +void _Cdecl MSetPos(int,int); // set cursor pixel position +void _Cdecl MGetStatus(); // Set button status and cur. position +void _Cdecl MHideCursor(); // don't display cursor +void _Cdecl MShowCursor(); // display cursor +void _Cdecl MSetMode(int); // set mouse display mode +void _Cdecl MAssignCursor(void far *);// assign new cursor design +}; + +extern int _Cdecl Mspressed; // #times a button pressed +extern int _Cdecl Msreleased; // #times a button released +extern int _Cdecl Msbutton; // 1=left button, 2=right button +extern int _Cdecl Msx; // horiz. screen position +extern int _Cdecl Msy; // vert. screen position +extern void _Cdecl *McursorArrow; // default cursor definition block + +#define LeftMButton 1 +#define RightMButton 2 + +#define MCopy_Put 0 // Mouse cursor display modes +#define MXor_Put 1 +#define MAnd_Put 2 +#define MOr_Put 3 +#define MNot_Put 4 + + diff --git a/super/MOUSEL.OBJ b/super/MOUSEL.OBJ new file mode 100644 index 0000000..5864041 Binary files /dev/null and b/super/MOUSEL.OBJ differ diff --git a/super/SUPER.BAK b/super/SUPER.BAK new file mode 100644 index 0000000..579a2e2 --- /dev/null +++ b/super/SUPER.BAK @@ -0,0 +1,109 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +int GraphDriver; /* The Graphics device driver */ +int GraphMode; /* The Graphics mode value */ +int ErrorCode; /* Reports any graphics errors */ + +void Initialize(void); +void Report(void); +int gprintf(int xloc, int yloc, char *fmt, ... ); +int huge detectVESA(void); + + +/* *** here we go *** */ +int main() +{ + + + + + Initialize(); /* Initialize Graphics mode */ + setfillstyle(1,245); + bar(0,0,getmaxx(),getmaxy()); + Report(); /* Tell the world what we found */ + MouseInit(); + + setcolor (124); + + MShowCursor(); + + line (100,100,800,800); + setcolor(150); + + +// Pause(); /* Give em a change to see it */ + + getch(); + MouseClose(); + closegraph(); /* Go home */ + return(0); +} + +// ************************************************************************ +// ************************************************************************ +// FUNCIONES DEL PROGRAMA +// ************************************************************************// ************************************************************************// ************************************************************************ +// ************************************************************************ + +int huge detectVESA(void) +{ return(2); } + +/* Initialize the graphics system and report any errors occur. */ +void Initialize(void) +{ + GraphDriver = installuserdriver("bgi256v2",detectVESA); + if (grOk != graphresult() ) + { + printf("Error installing VESA driver"); + exit(1); + } + GraphDriver = DETECT; + initgraph( &GraphDriver, &GraphMode, "c:\\c\\bgi" ); + ErrorCode = graphresult(); + if (ErrorCode != grOk) /* Check if error occured */ + { + printf(" Graphics System Error: %s\n",grapherrormsg(ErrorCode)); + exit(1); + } +} + + +void Report(void) +{ + char *driver, *mode; + driver = getdrivername(); + mode = getmodename(GraphMode); + gprintf(10,10,"Graphics device : %-20s (%d)",driver,GraphDriver); + gprintf(10,20,"Graphics mode : %-20s (%d)",mode,GraphMode); + gprintf(10,30,"Screen resolution : %d x %d",getmaxx(),getmaxy()); + gprintf(10,40,"Colors available : %d",getmaxcolor()+1); +} + + +/*GPRINTF: Used like PRINTF except the output is sent to the */ +/*screen in graphics mode at the specified co-ordinate. */ +int gprintf( int xloc, int yloc, char *fmt, ... ) +{ + va_list argptr; /* Argument list pointer */ + char str[140]; /* Buffer to build sting into */ + int cnt; /* Result of SPRINTF for return */ + va_start( argptr, format ); /* Initialize va_ functions */ + cnt = vsprintf( str, fmt, argptr ); /* prints string to buffer */ + outtextxy( xloc, yloc, str ); /* Send string in graphics mode */ + yloc += textheight( "H" ) + 2; /* Advance to next line */ + va_end( argptr ); /* Close va_ functions */ + return( cnt ); /* Return the conversion count */ +} + + + + + diff --git a/super/SUPER.C b/super/SUPER.C new file mode 100644 index 0000000..6c46994 --- /dev/null +++ b/super/SUPER.C @@ -0,0 +1,114 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +int GraphDriver; /* The Graphics device driver */ +int GraphMode; /* The Graphics mode value */ +int ErrorCode; /* Reports any graphics errors */ + +void Initialize(void); +void Report(void); +int gprintf(int xloc, int yloc, char *fmt, ... ); +int huge detectVESA(void); + + +/* *** here we go *** */ +int main() +{ + + + + + Initialize(); /* Initialize Graphics mode */ + for (int a=1;a<256;a++){ + setfillstyle(1,a); + bar(0,0,getmaxx(),getmaxy()); + gprintf (100,100,"%d",a); + //getch(); + delay(2000); + } + Report(); /* Tell the world what we found */ + MouseInit(); + + setcolor (124); + + MShowCursor(); + + line (100,100,800,800); + setcolor(150); + + +// Pause(); /* Give em a change to see it */ + + getch(); + MouseClose(); + closegraph(); /* Go home */ + return(0); +} + +// ************************************************************************ +// ************************************************************************ +// FUNCIONES DEL PROGRAMA +// ************************************************************************// ************************************************************************// ************************************************************************ +// ************************************************************************ + +int huge detectVESA(void) +{ return(2); } + +/* Initialize the graphics system and report any errors occur. */ +void Initialize(void) +{ + GraphDriver = installuserdriver("bgi256v2",detectVESA); + if (grOk != graphresult() ) + { + printf("Error installing VESA driver"); + exit(1); + } + GraphDriver = DETECT; + initgraph( &GraphDriver, &GraphMode, "c:\\c\\bgi" ); + ErrorCode = graphresult(); + if (ErrorCode != grOk) /* Check if error occured */ + { + printf(" Graphics System Error: %s\n",grapherrormsg(ErrorCode)); + exit(1); + } +} + + +void Report(void) +{ + char *driver, *mode; + driver = getdrivername(); + mode = getmodename(GraphMode); + gprintf(10,10,"Graphics device : %-20s (%d)",driver,GraphDriver); + gprintf(10,20,"Graphics mode : %-20s (%d)",mode,GraphMode); + gprintf(10,30,"Screen resolution : %d x %d",getmaxx(),getmaxy()); + gprintf(10,40,"Colors available : %d",getmaxcolor()+1); +} + + +/*GPRINTF: Used like PRINTF except the output is sent to the */ +/*screen in graphics mode at the specified co-ordinate. */ +int gprintf( int xloc, int yloc, char *fmt, ... ) +{ + va_list argptr; /* Argument list pointer */ + char str[140]; /* Buffer to build sting into */ + int cnt; /* Result of SPRINTF for return */ + va_start( argptr, format ); /* Initialize va_ functions */ + cnt = vsprintf( str, fmt, argptr ); /* prints string to buffer */ + outtextxy( xloc, yloc, str ); /* Send string in graphics mode */ + yloc += textheight( "H" ) + 2; /* Advance to next line */ + va_end( argptr ); /* Close va_ functions */ + return( cnt ); /* Return the conversion count */ +} + + + + + diff --git a/super/SUPER.DSK b/super/SUPER.DSK new file mode 100644 index 0000000..fc8c2ec Binary files /dev/null and b/super/SUPER.DSK differ diff --git a/super/SUPER.PRJ b/super/SUPER.PRJ new file mode 100644 index 0000000..f73b85d Binary files /dev/null and b/super/SUPER.PRJ differ