Advertisement
SrJefers_Loading

poitanpilas

Apr 5th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // MemoriaDinamica
  4. //
  5. // Created by Ricardo Poitán on 5/04/16.
  6. // Copyright © 2016 Ricardo Poitan. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <string>
  14.  
  15. using namespace std;
  16.  
  17. struct nodo
  18. {
  19. string dato;
  20. float espacio;
  21.  
  22. nodo *p;
  23. };
  24.  
  25. void Agregar(nodo **cab, nodo **fin);
  26. void Mostrar(nodo *cab);
  27.  
  28. int main()
  29. {
  30. nodo *c = NULL, *f = NULL;
  31. int opcion;
  32.  
  33. do{
  34. system("cls");
  35. cout << "MENU" << endl;
  36. cout << endl;
  37. cout << "1.)Registro" << endl;
  38. cout << "2.)Mostrar" << endl;
  39. cout << "3.)Salida" << endl;
  40. cout << "Opcion: " << endl;
  41. cin >> opcion;
  42.  
  43. switch (opcion)
  44. {
  45. case 1:
  46. Agregar(&c, &f);
  47. break;
  48.  
  49. case 2:
  50. Mostrar(c);
  51. break;
  52.  
  53. case 3:
  54. exit(0);
  55. break;
  56. }
  57.  
  58. }while(opcion != 3);
  59.  
  60. cin.get();
  61. cin.get();
  62. return 0;
  63. }
  64.  
  65. void Agregar(nodo **cab, nodo **fin)
  66. {
  67. string Num1;
  68. float Storage;
  69.  
  70. system("cls");
  71. cout << "Registro de Ordenadores Laboratorio de Computo UMG" << endl;
  72. cout << endl;
  73. cout << "Direccion IP: ";
  74. cin >> Num1;
  75. cout << "Espacio disponible en Disco Duro: ";
  76. cin >> Storage;
  77.  
  78. if((*cab) == NULL)
  79. {
  80. *cab = new nodo;
  81. (*cab)->dato = Num1;
  82. (*cab)->espacio = Storage;
  83. (*cab)->p = NULL;
  84. (*fin) = (*cab);
  85. }
  86. else
  87. {
  88. (*fin)->p = new nodo;
  89. (*fin)->p->dato = Num1;
  90. (*fin)->p->espacio = Storage;
  91. (*fin) = (*fin)->p;
  92. (*fin)->p = NULL;
  93. }
  94. }
  95.  
  96. void Mostrar(nodo *cab)
  97. {
  98. nodo *i;
  99. i = cab;
  100.  
  101. system("cls");
  102. cout << "Elementos en la lista: " << endl;
  103. cout << endl;
  104.  
  105. while(i != NULL)
  106. {
  107. cout << i->dato << "\t" << i->espacio << i->p << "\t" << "\t" << i << endl;
  108. i = i->p;
  109. }
  110. cin.get();
  111. cin.get();
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement