programa traductor de ingles-español

#include <iostream> #include <fstream> #include <stdlib.h> #include <time.h> #include <iomanip> #include <math.h> using namespace std; struct juego{ char nombre [20]; int correct; char pts[5]; }; juego apre; ofstream Datos("usuarios.txt",ios::app); void solicitar_nombre() { cout<<"ingrese su nombre:"; cin>>apre.nombre; } void GuardarenArchivo() { Datos.clear(); Datos.seekp(0, ios::end); Datos.write((char *) (&apre), sizeof(juego)); cout <<"El usuario "<< apre.nombre <<" se ha grabado en archivo"<< endl; } void guardar_puntos(){ Datos.clear(); Datos.seekp(0, ios::end); Datos.write((char *) (&apre), sizeof(juego)); cout <<"Los puntos "<< apre.pts <<" se ha grabado en archivo"<< endl; } int nofw; #define N 50 //definicion de la matriz de N filas. void pausa(); bool checkrep(int n, int num[])//para saber cuantas palabras deseo aprender. { for(int i=0; i<nofw; i++) if(n == num[i]) return true; return false; } void mostrar_palabras(){ system("cls"); cout<<" ------------------------------------------------------------ "<<endl; cout<<"| |"<<endl; cout<<"| 50 PALABRAS EN INGLES-ESPAÑOL |"<<endl; cout<<"| |"<<endl; cout<<" ------------------------------------------------------------- "<<endl; string words[50][2] = {{"hi", "hola"}, {"house", "casa"}, {"water", "agua"}, {"roof", "techo"}, {"chair", "silla"}, {"loudspeaker", "bocina"}, {"screen", "pantalla"}, {"money", "dinero"},{"one","uno"},{"two","dos"},{"three","tres"},{"four","cuatro"}, {"five","cinco"},{"six","seis"},{"seven","siete"},{"eight","ocho"},{"nine","nueve"},{"ten","diez"}, {"white","blanco"},{"black","negro"},{"red","rojo"},{"green","verde"},{"blue","azul"},{"purple","morado"}, {"brown","marron"},{"yellow","amarillo"},{"pink","rosado"},{"grey","gris"}, {"monday","lunes"},{"tuesday","martes"},{"wednesday","miercoles"},{"thursday","jueves"},{"friday","viernes"}, {"saturday","sabado"},{"sunday","domingo"},{"january","enero"},{"febrery","febrero"},{"march","marzo"},{"april","abril"}, {"may","mayo"},{"june","junio"},{"july","julio"},{"august","agosto"},{"september","septiembre"},{"october","octubre"}, {"november","noviembre"},{"december","diciembre"},{"tall","alto"},{"short","bajo"},{"big","grande"}}; cout<<"ingles español"<<endl<<endl; for(int i=0; i<50; i++) cout<<"["<<i+1<<"]"<<" "<<words[i][0]<<setw(16)<<words[i][1]<<endl; } void traduc_ingles(){ srand(time(NULL)); string ans, words[N][2] = {{"hi", "hola"}, {"house", "casa"}, {"water", "agua"}, {"roof", "techo"}, {"chair", "silla"}, {"loudspeaker", "bocina"}, {"screen", "pantalla"}, {"money", "dinero"},{"one","uno"},{"two","dos"},{"three","tres"},{"four","cuatro"}, {"five","cinco"},{"six","seis"},{"seven","siete"},{"eight","ocho"},{"nine","nueve"},{"ten","diez"}, {"white","blanco"},{"black","negro"},{"red","rojo"},{"green","verde"},{"blue","azul"},{"purple","morado"}, {"brown","marron"},{"yellow","amarillo"},{"pink","rosado"},{"grey","gris"}, {"monday","lunes"},{"tuesday","martes"},{"wednesday","miercoles"},{"thursday","jueves"},{"friday","viernes"}, {"saturday","sabado"},{"sunday","domingo"},{"january","enero"},{"febrery","febrero"},{"march","marzo"},{"april","abril"}, {"may","mayo"},{"june","junio"},{"july","julio"},{"august","agosto"},{"september","septiembre"},{"october","octubre"}, {"november","noviembre"},{"december","diciembre"},{"tall","alto"},{"short","bajo"},{"big","grande"}}; int n; int wrong=0; system("cls"); cout<<"-------------------------------------------------------------"<<endl; cout<<"| |"<<endl; cout<<"| APRENDE EL INGLES-ESPAÑOL FACIL |"<<endl; cout<<"| |"<<endl; cout<<"-------------------------------------------------------------"<<endl; cout<<"Ingrese el numero de palabras que quiere aprender: "; cin >> nofw; int num[nofw]; for(int i=0; i<nofw; i++) { do n = rand() % N; while(checkrep(n, num)); num[i] = n; cout << words[n][0]<<endl; } cin.get(); cin.get(); system("cls"); cout<<"-------------------------------------------------------------"<<endl; cout<<"| |"<<endl; cout<<"| PANTALLA DE TRADUCCION |"<<endl; cout<<"| |"<<endl; cout<<"-------------------------------------------------------------"<<endl; for(int i=0; i<nofw; i++) { cout << words[num[i]][0] <<endl; cout<<"ingrese la traduccion al Español:"; cin>>ans; cout<<endl; if(ans == words[num[i]][1]) { apre.correct++; cout << "La traduccion fue correcta"<<endl; cout<<"________________________________________"<<endl; } else { wrong++; cout << "La traduccion fue incorrecta"<<endl; cout<<"________________________________________"<<endl; } } if(apre.correct>0) { cout<<endl; cout<<" Fuiste acreedor de: "<<apre.correct*5 <<" pst sigue aprendiendo mas...... "<<endl; cout<<" Tuviste un "<<(float)apre.correct/(float)nofw*100<<"% de respuestas correctas. "<<endl; } else { cout<<endl; cout<<" Debes seguir practicando mas, vuelve a intentar..... "<<endl; cout<<" Tuviste un "<<(float)apre.correct/(float)nofw*100<<"% de respuestas correctas. "<<endl; } cin.get(); cin.get(); } void traduc_esp() { srand(time(NULL)); string ans, words[N][2] = {{"hi", "hola"}, {"house", "casa"}, {"water", "agua"}, {"roof", "techo"}, {"chair", "silla"}, {"loudspeaker", "bocina"}, {"screen", "pantalla"}, {"money", "dinero"},{"one","uno"},{"two","dos"},{"three","tres"},{"four","cuatro"}, {"five","cinco"},{"six","seis"},{"seven","siete"},{"eight","ocho"},{"nine","nueve"},{"ten","diez"}, {"white","blanco"},{"black","negro"},{"red","rojo"},{"green","verde"},{"blue","azul"},{"purple","morado"}, {"brown","marron"},{"yellow","amarillo"},{"pink","rosado"},{"grey","gris"}, {"monday","lunes"},{"tuesday","martes"},{"wednesday","miercoles"},{"thursday","jueves"},{"friday","viernes"}, {"saturday","sabado"},{"sunday","domingo"},{"january","enero"},{"febrery","febrero"},{"march","marzo"},{"april","abril"}, {"may","mayo"},{"june","junio"},{"july","julio"},{"august","agosto"},{"september","septiembre"},{"october","octubre"}, {"november","noviembre"},{"december","diciembre"},{"tall","alto"},{"short","bajo"},{"big","grande"} }; int n, correct=0, wrong=0; system("cls"); cout<<"-------------------------------------------------------------"<<endl; cout<<"| |"<<endl; cout<<"| APRENDE EL INGLES-ESPAÑOL FACIL |"<<endl; cout<<"| |"<<endl; cout<<"-------------------------------------------------------------"<<endl; cout<<"Ingrese el numero de palabras que quiere aprender: "; cin >> nofw; int num[nofw]; for(int i=0; i<nofw; i++) { do n = rand() % N; while(checkrep(n, num)); num[i] = n; cout << words[n][1]<<endl; } cin.get(); cin.get(); system("cls"); cout<<"-------------------------------------------------------------"<<endl; cout<<"| |"<<endl; cout<<"| PANTALLA DE TRADUCCION |"<<endl; cout<<"| |"<<endl; cout<<"-------------------------------------------------------------"<<endl; for(int i=0; i<nofw; i++) { cout << words[num[i]][1] <<endl; cout<<"ingrese la traduccion al Ingles:"; cin>>ans; cout<<endl; if(ans == words[num[i]][0]) { //correct*5; correct++; cout << "La traduccion fue correcta"<<endl; cout<<"________________________________________"<<endl; } else { wrong++; cout << "La traduccion fue incorrecta"<<endl; cout<<"________________________________________"<<endl; } } if(apre.correct>0) { cout<<endl; cout<<" Fuiste acreedor de: "<<correct*5 <<" pst sigue aprendiendo mas...... "<<endl; cout<<" Tuviste un "<<(float)correct/(float)nofw*100<<"% de respuestas correctas. "<<endl; } else { cout<<endl; cout<<" Debes seguir practicando mas, vuelve a intentar..... "<<endl; cout<<" Tuviste un "<<(float)correct/(float)nofw*100<<"% de respuestas correctas. "<<endl; } cin.get(); cin.get(); } int main() { bool opc; solicitar_nombre(); bool pau1=false; int opc1; do{ system("cls"); cin.clear(); cout<<" ------------------------------------------------------------ "<<endl; cout<<"| |"<<endl; cout<<"| BIENVENIDOS A TRADUCE Y APRENDE |"<<endl; cout<<"| |"<<endl; cout<<" ------------------------------------------------------------- "<<endl; cout<<"1. Traducir al español"<<endl; cout<<"2. Traducir al ingles"<<endl; cout<<"3. Mostrar palabras"<<endl; cout<<"4. salir"<<endl; cout<<endl; cout<<"elija una opcion:"; cin>>opc1; bool ingresar_otro; switch (opc1){ case 1: do{ traduc_ingles(); cout<<"Desea continuar? SI[1], NO[0]"<<endl; cin>>ingresar_otro; guardar_puntos(); }while(ingresar_otro); break; case 2: do{ traduc_esp(); cout<<"Desea continuar? SI[1], NO[0]"<<endl; cin>>ingresar_otro; }while(ingresar_otro); break; case 3: mostrar_palabras(); pausa(); break; case 4: pau1=true; break; }}while (pau1!=true); return 0; } void pausa() { cout << "Pulsa la tecla -ENTER- para continuar..."; getwchar(); getwchar(); }

1 Response

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.