Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #define puntero nodo2*
- using namespace std;
- struct nodo1 {
- char valor;
- nodo1* next;
- };
- struct nodo2 {
- int grupo;
- nodo2* next;
- nodo1* sublista;
- };
- struct lista {
- nodo2* root;
- };
- struct registro {
- int grupo;
- char valor;
- };
- nodo2* crear()
- {
- nodo2* p = nullptr;
- return p;
- }
- bool leer_especial (ifstream& input, registro R)
- {
- if (not input.eof())
- {
- input >> R.grupo >> R.valor;
- return true;
- }
- else
- return false;
- }
- void insertar_grupo (nodo2*& p, int grupo)
- {
- }
- void insertar_valor_en_grupo (nodo2*& p, int grupo, char valor)
- {
- }
- void fusionar (const string& n, const lista& l, nodo2*& p)
- {
- ifstream input (n, ios::binary); registro R; int grupo_ant;
- nodo2* lista = l.root;
- nodo1* sublista;
- p = crear();
- bool b = leer_especial(input,R);
- while (lista != 0 and b)
- {
- if (lista->grupo < R.grupo)
- {
- insertar_grupo(p, lista->grupo);
- sublista = lista->sublista;
- while(sublista != nullptr)
- {
- insertar_valor_en_grupo(p, lista->grupo, sublista->valor);
- sublista = sublista->next;
- }
- lista = lista->next;
- }
- else if (lista->grupo > R.grupo)
- {
- insertar_grupo(p, R.grupo);
- grupo_ant = R.grupo;
- while (b and R.grupo == grupo_ant)
- {
- insertar_valor_en_grupo(p, R.grupo, R.valor);
- }
- }
- else if (lista->grupo == R.grupo)
- {
- insertar_grupo(p, lista->grupo);
- sublista = lista->sublista;
- while(sublista != nullptr)
- {
- insertar_valor_en_grupo(p, lista->grupo, sublista->valor);
- sublista = sublista->next;
- }
- lista = lista->next;
- grupo_ant = R.grupo;
- while (b and R.grupo == grupo_ant)
- {
- insertar_valor_en_grupo (p, R.grupo, R.valor);
- b = leer_especial(input, R);
- }
- }
- if (lista == nullptr)
- {
- while (b)
- {
- insertar_grupo (p, R.grupo);
- grupo_ant = R.grupo;
- while (b and R.grupo == grupo_ant)
- {
- insertar_valor_en_grupo(p, R.grupo, R.valor);
- b = leer_especial (input, R);
- }
- }
- }
- else
- {
- while (lista != nullptr)
- {
- insertar_grupo (p, lista->grupo);
- grupo_ant = lista->grupo;
- sublista = lista->sublista;
- while (sublista != nullptr)
- {
- insertar_valor_en_grupo(p, lista->grupo, sublista->valor);
- sublista = sublista->next;
- }
- lista = lista->next;
- }
- }
- }
- }
- int main()
- {
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement