Sayukoo

[LISTY]Wypisanie 3 list

Dec 17th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.  
  6. struct osoba{
  7.     struct osoba *next;
  8.     int wiek;
  9.     int wzrost;
  10. };
  11.  
  12. void wypisz(struct osoba*lista)
  13. {
  14.      struct osoba*pom=lista;
  15.  
  16.      while(pom!=NULL)
  17.      {
  18.          printf("%d\n ",pom->wiek);
  19.          printf("%d\n ",pom->wzrost);
  20.          pom=pom->next;
  21.      }
  22. }
  23.  
  24. int main()
  25. {
  26.     struct osoba *pocz;
  27.  
  28.     pocz=(struct osoba*)malloc(sizeof(struct osoba));
  29.  
  30.     pocz->wiek=5;
  31.     pocz->wzrost=190;
  32.  
  33.     struct osoba *pom;
  34.     pom=(struct osoba*)malloc(sizeof(struct osoba));
  35.     pocz->next=pom;
  36.     pom->wiek=6;
  37.     pom->wzrost=160;
  38.  
  39.     struct osoba *trzeci;
  40.     trzeci=(struct osoba*)malloc(sizeof(struct osoba));
  41.     pom->next=trzeci;
  42.     trzeci->wiek=7;
  43.     trzeci->wzrost=123;
  44.     trzeci->next=NULL;
  45.  
  46.     wypisz(pocz);
  47.  
  48.  
  49.     return 0;
  50. }
Add Comment
Please, Sign In to add comment