Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. struct buono{
  7. char id[10+1];
  8. char dataEmissione[10+1];
  9. char emailCliente[250+1];
  10. float valore;
  11. char dataScadenza[10+1];
  12. unsigned int stato;
  13. };
  14.  
  15. struct nodo{
  16. buono info;
  17. nodo*next;
  18. };
  19.  
  20. nodo* creaNodo(buono b){
  21. nodo* n = new nodo;
  22. if(n == NULL) {
  23. return NULL;
  24. }
  25. else{
  26. n->info = b;
  27. n->next = NULL;
  28. }
  29. }
  30.  
  31. nodo* inserimentoTesta(nodo* lista, nodo* n){
  32. if(lista == NULL) return n;
  33. if (n == NULL) return lista;
  34. n->next = lista;
  35. return n;
  36. }
  37.  
  38. void stampaLista(nodo* lista){
  39. if(lista != NULL){
  40. cout<<"ID : "<<(lista->info).id;
  41. stampaLista(lista->next);
  42. }
  43. }
  44.  
  45. int main(){
  46. nodo* lista = NULL;
  47. int numeroNodi;
  48.  
  49. cout<<"Quanti nodi : ";
  50. cin>>numeroNodi;
  51.  
  52. buono b = NULL;
  53. for(int i=0; i<numeroNodi; i++){
  54. b = new buono;
  55. b.id = i;
  56. nodo* temp = creaNodo(b);
  57. inserimentoTesta(lista, temp);
  58. }
  59.  
  60. stampaLista(lista);
  61. //system("PAUSE");
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement