Kod: |
#include "ATP List.c"
#include <stdio.h> #include <stdlib.h> /* Test za ATP List */ void ispis(List L) { if(L->next==NULL) {printf("Lista prazna."); return 0;} position q=L; while(q!=LiEnd(L)) {printf("%d, ", LiRetrieve(q)); q=q->next;} return; } int main(void) { List L; position p; LiMakeNull(&L); p=L; int i; for(i=0; i<5; i++) { LiInsert(i, p); } ispis(L); return 0; } |
Kod: |
typedef celltype* List;
typedef celltype* position; position LiMakeNull(List *L) { (*L)=(celltype*) malloc(sizeof(celltype)); (*L)->next=NULL; return *L; } position LiEnd(List L) { position q; q=L; while (q->next!=NULL) q=q->next; return q; } void LiInsert(elementtype y, position p) { position temp; temp=p->next; p->next=(celltype*)malloc(sizeof(celltype)); p->next->x=y; p->next->next=temp; free(temp); return; } |
output generated using printer-friendly topic mod. Vremenska zona: GMT + 01:00.