+void get_file (const char *f, std::map<int,std::string> &out, int &cant)
+{
+ std::ifstream reader (f);
+ cant = 0;
+ char l[100];
+
+ while (!reader.eof ()) {
+ reader.getline (l, 100);
+ out[cant] = std::string (l);
+ cant++;
+ }
+}
+
+
+void generar_aleatorio (std::list<std::string> &lst, uint n)
+{
+ std::map<int, std::string> productos;
+ std::map<int, std::string> marcas;
+ int productos_cant, marcas_cant;
+
+ get_file ("productos.txt", productos, productos_cant);
+ get_file ("marcas.txt", marcas, marcas_cant);
+
+ srand (time (NULL));
+ int random1, random2;
+ /* TODO : Evitar repetidos */
+ for (uint i=0; i < n; i++) {
+ random1 = 1 + (int)(productos_cant * (float)rand () / (RAND_MAX + 1.0f));
+ random2 = 1 + (int)(marcas_cant * (float)rand () / (RAND_MAX + 1.0f));
+
+ lst.push_back (productos[random1-1] + " " + marcas[random2-1]);
+ }
+}
+