Advertisement
Guest User

final creo

a guest
Jun 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1.  
  2. #pragma once
  3. #include "pch.h"
  4. #include <string>
  5. using namespace std;
  6.  
  7. enum NIVEL_DE_GRASA {
  8. ALTO = 3, MEDIO = 2, BAJO = 1
  9. };
  10.  
  11. struct Paty {
  12. float precio;
  13. NIVEL_DE_GRASA nivelDeGrasa;
  14. int grosor;
  15. };
  16.  
  17.  
  18.  
  19. ////////////////////////
  20.  
  21. ListaPaty* listaPatyCreate() {
  22. ListaPaty *lista = new ListaPaty;
  23. lista->primerElemento = NULL;
  24. return lista;
  25. }
  26.  
  27. NodoPaty* nodoPatyCreate(Paty *unPaty) {
  28. NodoPaty *unNodo = new NodoPaty;
  29. unNodo->unPaty = unPaty;
  30. unNodo->siguiente = NULL;
  31. return unNodo;
  32. }
  33.  
  34.  
  35. /////////////////
  36.  
  37. void listaPatyAgregarNodo(ListaPaty *lista, NodoPaty *nodoPaty) {
  38. if (listaPatyEstaVacia(lista)) {
  39. lista->primerElemento = nodoPaty;
  40. }
  41. else {
  42. NodoPaty *ultimoNodo = listaPatyUltimoElemento(lista);
  43. ultimoNodo->siguiente = nodoPaty;
  44. }
  45. }
  46.  
  47. bool listaPatyEstaVacia(ListaPaty *lista) {
  48. return lista->primerElemento == NULL;
  49. }
  50.  
  51. NodoPaty* listaPatyUltimoElemento(ListaPaty *lista) {
  52. NodoPaty *nodoAuxiliar = lista->primerElemento;
  53. while (nodoAuxiliar->siguiente != NULL) {
  54. nodoAuxiliar = nodoAuxiliar->siguiente;
  55. }
  56. return nodoAuxiliar;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement