Está en la página 1de 5

#include"stdio.

h"
#include"conio.h"
#include"ctype.h"
#include"string.h"
void
void
void
void
char
void
void
void

load(void);
enter(void);
marco(int col1,int fil1,int col2,int fil2);
clear(int col1,int fil1,int col2,int fil2,int color);
buscado(char palabra[20],int e);
registro(void);
menu(void);
limpiar(void);

struct registro
{
char ingles[20];
char espanol[20];
}traducida;
int x=0,y=0;
main()
{
char texto[','];
char palabra[20];
char caracter;
char TECLA;
int posi=0,pos=0,x=9,s=0,o=0;
textbackground(0);
clrscr();
load();
enter();
clrscr();
menu();
do
{
textcolor(15);
textbackground(0);
gotoxy(40,8);cprintf("MENU");
gotoxy(32,10);cprintf(" REGISTRAR PALABRAS ");
gotoxy(32,11);cprintf(" BAJA DE PALABRA ");
gotoxy(32,12);cprintf(" TRADUCIR TEXTOS ");
if(x==10)
{
textcolor(14);
textbackground(4);
gotoxy(32,10);cprintf(" registrar palabras ");
}
if(x==11)
{
textcolor(14);
textbackground(4);
gotoxy(32,11);cprintf(" baja de palabra ");
}
if(x==12)
{
textcolor(14);
textbackground(4);

gotoxy(32,12);cprintf(" traducir textos ");


}
gotoxy(32,x);
TECLA=getch();
if(TECLA=='H')
{
if(x>10)
x--;
else
x=12;
}
if(TECLA=='P')
{
if(x<12)
x++;
else
x=10;
}
if(x==10)
{
textbackground(1);
gotoxy(32,10);cprintf(" REGISTRAR PALABRAS ");
}
if(TECLA==13 && x==12)
{
posi=0;
clear(2,2,78,23,0);
marco(2,2,78,11);
marco(2,13,78,23);
marco(3,4,77,10);
marco(3,15,77,22);
gotoxy(39,3);printf("INGLES");
gotoxy(39,14);printf("ESPAOL");
gotoxy(5,5);
gets(texto);
strupr(texto);
o=strlen(texto);
while(posi<=o)
{
caracter=texto[posi];
if(caracter==NULL || caracter==' ')
{
buscado(palabra,pos);
for(s=0;s<=20;s++){palabra[s]='';}
pos=0;
}
else
{
palabra[pos]=caracter;
pos++;
}
posi++;
}
getch();
caracter='a';
clear(2,2,78,23,0);
menu();
pos=0;
y=0;
}

if(TECLA==13 && x==10)


{
clear(2,2,78,23,0);
marco(2,2,78,4);
marco(2,6,78,23);
gotoxy(32,3);cprintf("REGISTRO DE PLALABRAS");
marco(5,10,24,12);
marco(25,10,54,12);
marco(5,13,24,15);
marco(25,13,54,15);
gotoxy(6,11);cprintf("PALABRA EN INGLES");
gotoxy(6,14);cprintf("PALABRA EN ESPAOL");
limpiar();
gotoxy(26,11);gets(traducida.ingles);
gotoxy(26,14);gets(traducida.espanol);
strupr(traducida.ingles);
strupr(traducida.espanol);
registro();
getch();
clear(2,2,78,23,0);
menu();
}
}while(TECLA!=27);
}
void limpiar(void){int x; for(x=0;x<=19;x++){traducida.ingles[x]=''; traducida.e
spanol[x]='';}}
void menu(void)
{
textbackground(0);
textmode(3);
marco(1,1,80,24);
marco(2,2,78,22);
marco(31,9,52,13);
marco(30,7,53,14);
}
void registro(void)
{
FILE *archivo;
if((archivo=fopen("C:Diccionario.txt","a+"))==NULL)
{
clear(1,1,80,24,0);
gotoxy(26,12);printf("ERROR EL ARCHIVO NO EXISTE");
getch();
exit(0);
}
fwrite(&traducida,sizeof(traducida),1,archivo);
fclose(archivo);
}
char buscado(char palabra[20],int e)
{
FILE *archivo;
int trad=0,m=0,dimencion=0;
if((archivo=fopen("C:Diccionario.txt","r"))==NULL)
{
clear(1,1,80,24,0);
gotoxy(26,12);printf("ERROR EL ARCHIVO NO EXISTE");
getch();
exit(0);
}
rewind(archivo);

while(!(feof(archivo)))
{
fread(&traducida,sizeof(traducida),1,archivo);
m=strlen(traducida.ingles);
if(e<=3)
{
if(palabra[0]==traducida.ingles[0] && palabra[1]==traducida.in
gles[1] &&
palabra[2]==traducida.ingles[2])
{
trad=1;
break;
}
}
else
if(stricmp(palabra,traducida.ingles)==0)
{
trad=1;
break;
}
}
fclose(archivo);
if(trad==0)
{
for(m=0;m<e;m++)
{
gotoxy(5+m+y,16);
printf("%c",palabra[m]);
}
}
else
{
dimencion=strlen(traducida.espanol);
gotoxy(5+y,16);printf("%s ",traducida.espanol);
y+=dimencion-4;
}
y=y+e+2+dimencion;
fclose(archivo);
}
void clear(int col1,int fil1,int col2,int fil2,int color)
{
int x,y;
textbackground(color);
for(x=col1;x<=col2;x++)
for(y=fil1;y<=fil2;y++)
{
gotoxy(x,y);
cprintf(" ");
}
}
void marco(int col1,int fil1,int col2,int fil2)
{
int x;
textbackground(0);
textcolor(15);
for(x=col1;x<col2;x++){gotoxy(x,fil1);cprintf("%c",205);
gotoxy(x,fil2);cprintf("%c",205);}
for(x=fil1;x<=fil2;x++){gotoxy(col1,x);cprintf("%c",179);
gotoxy(col2,x);cprintf("%c",179);}
gotoxy(col1,fil1);cprintf("%c",213);gotoxy(col2,fil1);cprintf("%c",184)

;
gotoxy(col1,fil2);cprintf("%c",212);gotoxy(col2,fil2);cprintf("%c",190)
;
}
void enter(void)
{
int x=1;
clrscr();
while(!kbhit())
{
textmode(0);
textcolor(x);
gotoxy(3,24);
cprintf("PRESIONA CUALQUIER TECLA PARA INICIAR");
delay(2500);
if(x<=15)
{
x++;
}
else
{
x=1;
}
}
}
void load(void)
{
int x,por;
textcolor(15);
gotoxy(37,11);
cprintf("CARGANDO");
marco(24,10,57,15);
for(x=1;x<=30;x++)
{
textcolor(1);
gotoxy(25+x,12);
cprintf("%c",178,178);
}
for(x=1;x<=30;x++)
{
textcolor(15);
gotoxy(25+x,12);
cprintf("%c",178,178);
por=(x/3)*10;
gotoxy(39,13);textcolor(15);cprintf("%d%",por);
delay(100000);
}
}

También podría gustarte