SHARE
TWEET

Untitled

a guest Nov 19th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct listaelem{
  5.     int adat;
  6.     struct listaelem* next;
  7. }*lptr, lelem;
  8.  
  9. int pozitiv(int x) {
  10.     return x > 0;
  11. }
  12.  
  13. void printlist(lptr head){
  14.     lptr p;
  15.     for (p = head; p->next != NULL; p = p->next) {
  16.         if (pozitiv(p->adat) == 1)
  17.             printf("%d", p->adat);
  18.     }
  19. }
  20.  
  21. lptr beszur(lptr head, int adat) {
  22.     lptr uj = (lptr)malloc(sizeof(lelem));
  23.     if (uj == NULL)
  24.         return 0;
  25.     uj->adat = adat;
  26.     uj->next = head;
  27.     return uj;
  28. }
  29.  
  30. int main()
  31. {
  32.     lptr head=NULL;
  33.     beszur(head, 2);
  34.     beszur(head, -2);
  35.     beszur(head, -4);
  36.     beszur(head, 6);
  37.     beszur(head, 9);
  38.  
  39.     printlist(head);
  40.  
  41.  
  42.     return 0;
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top