Dec 15, 2011

Learn English, are in C++!?


SetRoot told me through a comment that came to a C + + that will help you learn words in English, in his own words:
Se me ocurrio hacer un programa para aprender ingles y creo que los tiros tambien van por ahi corrígeme:
1 llenar 1000 palabras
2 agruparlas por alguna relacion como emociones articulos y otros(para esto quisiera usar una matriz para acceder a ella mas facil aunque 2 matrices tambien creo q me van :s con punteros y eso ,s)
3 ejecucion: con un par de cases hacer un menu que me permita lanzar 20 palabras al azar(con sran o ran creo + time) con su significado
y despues que me permita hacer un tipo de examen o test con esas mismas palabras desordenadas que cada acierto valga algo para ganar puntos y asi involucrar a los amigos y familiares

I liked the idea of doing a little 'sketch' of his idea precisely because we need to use the code from my last post: Random numbers without repeating in C++ . So my algorithm goes like this:
  1. Create an array string type N rows and 2 columns, the first column are the words in English, the second in Spanish.
  2. Order the number of words that the user wants to store.
  3. Getting that number of words and display them randomly.
  4. Delete the words and begin to ask the meaning of each.
  5. Compare the response of the user with the correct answer.
  6. Calculate your score and display it.
The code is this:
 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 # Include <cstdlib>
 # Include <ctime>
 # Include <iostream>
 using namespace std;

 nofw int;
 # Define N 8 / / number of pairs of words in the matrix

 checkRep bool (int n, int num [])
 {
     for (int i = 0; i <nofw i + +)
         if (n == num [i])
             return true;
     return false;
 }

 int main ()
 {
     srand (time (NULL));
     ans string, words [N] [2] = {{"hi", "hello"}, {"house", "home"}, {"water", "water"}, 
       {"Roof", "roof"}, {"chair", "chair"}, {"loudspeaker", "horn"}, 
       {"Screen", "display"}, {"money", "money"}};
     int n, correct = 0 wrong = 0;
     court <<"Number of words?:" cin>> nofw;
     / / Get 'nofw' words at random from our parent
     int num [nofw];
     for (int i = 0; i <nofw i + +)
     {
         do
             n = rand ()% N;
         while (checkRep (n, num));
         num [i] = n;
         court <<words [n] [0] <<"->" <<words [n] [1] <<endl;
     }
     cin. get (); cin. get ();
     system ("cls");
     / / Ask the meaning of each word
     for (int i = 0; i <nofw i + +)
     {
         court <<words [num [i]] [0] <<"=" cin>> ans;
         if (ans == words [num [i]] [1])
         {
             correct + +;
             court <<">> Good:) \ n \ n";
         }
         else
         {
             wrong + +;
             court <<">> Bad: (\ n \ n";
         }
     }
     court <<"You had a" <<(float) correct / (float) nofw * 100 << 
                 "% Of correct answers."
     cin. get (); cin. get ();
 } 
As I said before, it is only a sketch, but perhaps the starting point for a good project. To optimize think they should add a few things:
  • Get the word pairs from a database
  • Sort by category
  • That does not matter if the answer is case sensitive
  • Improve user interaction

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Premium Wordpress Themes