Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct listaelem{
- int adat;
- struct listaelem* next;
- }*lptr, lelem;
- int pozitiv(int x) {
- return x > 0;
- }
- void printlist(lptr head){
- lptr p;
- for (p = head; p->next != NULL; p = p->next) {
- if (pozitiv(p->adat) == 1)
- printf("%d", p->adat);
- }
- }
- lptr beszur(lptr head, int adat) {
- lptr uj = (lptr)malloc(sizeof(lelem));
- if (uj == NULL)
- return 0;
- uj->adat = adat;
- uj->next = head;
- return uj;
- }
- int main()
- {
- lptr head=NULL;
- beszur(head, 2);
- beszur(head, -2);
- beszur(head, -4);
- beszur(head, 6);
- beszur(head, 9);
- printlist(head);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement