Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // MemoriaDinamica
- //
- // Created by Ricardo Poitán on 5/04/16.
- // Copyright © 2016 Ricardo Poitan. All rights reserved.
- //
- #include <iostream>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <string>
- using namespace std;
- struct nodo
- {
- string dato;
- float espacio;
- nodo *p;
- };
- void Agregar(nodo **cab, nodo **fin);
- void Mostrar(nodo *cab);
- int main()
- {
- nodo *c = NULL, *f = NULL;
- int opcion;
- do{
- system("cls");
- cout << "MENU" << endl;
- cout << endl;
- cout << "1.)Registro" << endl;
- cout << "2.)Mostrar" << endl;
- cout << "3.)Salida" << endl;
- cout << "Opcion: " << endl;
- cin >> opcion;
- switch (opcion)
- {
- case 1:
- Agregar(&c, &f);
- break;
- case 2:
- Mostrar(c);
- break;
- case 3:
- exit(0);
- break;
- }
- }while(opcion != 3);
- cin.get();
- cin.get();
- return 0;
- }
- void Agregar(nodo **cab, nodo **fin)
- {
- string Num1;
- float Storage;
- system("cls");
- cout << "Registro de Ordenadores Laboratorio de Computo UMG" << endl;
- cout << endl;
- cout << "Direccion IP: ";
- cin >> Num1;
- cout << "Espacio disponible en Disco Duro: ";
- cin >> Storage;
- if((*cab) == NULL)
- {
- *cab = new nodo;
- (*cab)->dato = Num1;
- (*cab)->espacio = Storage;
- (*cab)->p = NULL;
- (*fin) = (*cab);
- }
- else
- {
- (*fin)->p = new nodo;
- (*fin)->p->dato = Num1;
- (*fin)->p->espacio = Storage;
- (*fin) = (*fin)->p;
- (*fin)->p = NULL;
- }
- }
- void Mostrar(nodo *cab)
- {
- nodo *i;
- i = cab;
- system("cls");
- cout << "Elementos en la lista: " << endl;
- cout << endl;
- while(i != NULL)
- {
- cout << i->dato << "\t" << i->espacio << i->p << "\t" << "\t" << i << endl;
- i = i->p;
- }
- cin.get();
- cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement