Advertisement
rihardmarius

final 7.12.13

Dec 13th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #define puntero nodo2*
  4.  
  5. using namespace std;
  6.  
  7. struct nodo1 {
  8.     char valor;
  9.     nodo1* next;
  10. };
  11.  
  12. struct nodo2 {
  13.     int grupo;
  14.     nodo2* next;
  15.     nodo1* sublista;
  16. };
  17.  
  18. struct lista {
  19.     nodo2* root;
  20. };
  21.  
  22. struct registro {
  23.     int grupo;
  24.     char valor;
  25. };
  26.  
  27. nodo2* crear()
  28. {
  29.     nodo2* p = nullptr;
  30.     return p;
  31. }
  32.  
  33. bool leer_especial (ifstream& input, registro R)
  34. {
  35.     if (not input.eof())
  36.     {
  37.         input >> R.grupo >> R.valor;
  38.         return true;
  39.     }
  40.     else
  41.         return false;
  42. }
  43.  
  44. void insertar_grupo (nodo2*& p, int grupo)
  45. {
  46.  
  47. }
  48.  
  49. void insertar_valor_en_grupo (nodo2*& p, int grupo, char valor)
  50. {
  51.  
  52. }
  53.  
  54. void fusionar (const string& n, const lista& l, nodo2*& p)
  55. {
  56.     ifstream input (n, ios::binary); registro R; int grupo_ant;
  57.     nodo2* lista = l.root;
  58.     nodo1* sublista;
  59.     p = crear();
  60.  
  61.     bool b = leer_especial(input,R);
  62.     while (lista != 0 and b)
  63.     {
  64.         if (lista->grupo < R.grupo)
  65.         {
  66.             insertar_grupo(p, lista->grupo);
  67.             sublista = lista->sublista;
  68.             while(sublista != nullptr)
  69.             {
  70.                 insertar_valor_en_grupo(p, lista->grupo, sublista->valor);
  71.                 sublista = sublista->next;
  72.             }
  73.             lista = lista->next;
  74.         }
  75.         else if (lista->grupo > R.grupo)
  76.         {
  77.             insertar_grupo(p, R.grupo);
  78.             grupo_ant = R.grupo;
  79.             while (b and R.grupo == grupo_ant)
  80.             {
  81.                 insertar_valor_en_grupo(p, R.grupo, R.valor);
  82.             }
  83.         }
  84.         else if (lista->grupo == R.grupo)
  85.         {
  86.             insertar_grupo(p, lista->grupo);
  87.             sublista = lista->sublista;
  88.             while(sublista != nullptr)
  89.             {
  90.                 insertar_valor_en_grupo(p, lista->grupo, sublista->valor);
  91.                 sublista = sublista->next;
  92.             }
  93.             lista = lista->next;
  94.             grupo_ant = R.grupo;
  95.             while (b and R.grupo == grupo_ant)
  96.             {
  97.                 insertar_valor_en_grupo (p, R.grupo, R.valor);
  98.                 b = leer_especial(input, R);
  99.             }
  100.         }
  101.         if (lista == nullptr)
  102.         {
  103.             while (b)
  104.             {
  105.                 insertar_grupo (p, R.grupo);
  106.                 grupo_ant = R.grupo;
  107.                 while (b and R.grupo == grupo_ant)
  108.                 {
  109.                     insertar_valor_en_grupo(p, R.grupo, R.valor);
  110.                     b = leer_especial (input, R);
  111.                 }
  112.             }
  113.         }
  114.         else
  115.         {
  116.             while (lista != nullptr)
  117.             {
  118.                 insertar_grupo (p, lista->grupo);
  119.                 grupo_ant = lista->grupo;
  120.                 sublista = lista->sublista;
  121.                 while (sublista != nullptr)
  122.                 {
  123.                     insertar_valor_en_grupo(p, lista->grupo, sublista->valor);
  124.                     sublista = sublista->next;
  125.                 }
  126.                 lista = lista->next;
  127.             }
  128.         }
  129.     }
  130. }
  131.  
  132.  
  133. int main()
  134. {
  135.     cout << "Hello world!" << endl;
  136.     return 0;
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement