typedef struct link int data struct link next
- Slides: 19
רשימה משורשרת typedef struct link{ int data; struct link * next; }link;
העומד בתור התאורטי void insert. Last(link * head, link * new. Link){ while (head->next!=NULL) head=head->next; head->next=new. Link; new. Link->next=NULL; }
" "אני אחריך void insert. After (link *where, link *new. Link){ new. Link->next=where->next; where->next=new. Link; }
" "אני לפניך link * insert. Before (link *head, link *where, link *new. Link){ if (head==where){ new. Link->next=head; return new. Link; } while (head->next!=where) head=head->next; new. Link->next=head->next; head->next=new. Link; return head; }
" "אני רק שאלה link * insert. First (link *head, link *new. Link){ new. Link->next=head; return new. Link; }
פונקציות עזר void print. List(link *head){ while (head){ printf("%d -> ", head->data); head=head->next; } printf("n"); } link * create. Link(int data, link * next){ link * l=(link *)malloc(sizeof (link)); if (l){ l->data=data; l->next=next; } return l; }
main void main(){ link * head; head=create. Link(5, NULL); print. List(head); head=insert. First(head, create. Link(7, NULL)); print. List(head); insert. Last(head, create. Link(9, NULL)); print. List(head); head=insert. Before(head, head->next, create. Link(3, NULL)); print. List(head); insert. After(head->next, create. Link(4, NULL)); print. List(head); }
"? ? "יש כרטיס מועדון link * remove. First(link * head){ link *temp=head; head=head->next; free(temp); return head; }
משפרי עמדה link * remove. Last(link * head){ link * temp=head; if (head->next==NULL){ free(head); return NULL; } while (head->next != NULL) head=head->next; free(head->next); head->next=NULL; return temp; }
" "שכחתי לקנות במבה link * remove. Link(link *head, link *to. Remove){ link * temp=head; if (head==to. Remove) return remove. First(head); while (head->next != to. Remove) head=head->next; head->next=head->next; free(to. Remove); return temp; }
void הפיכת פונקציה ל link * insert. First(link *head, link *new. Link){ new. Link->next=head; return new. Link; } void insert. First(link **head, link *new. Link){ new. Link->next=*head; *head=new. Link; }
הסתכלות רקורסיבית int find. Max(link * head){ int rest. Max; if (head==NULL) return 0; rest. Max = find. Max(head->next); if (rest. Max > head->data) return rest. Max; return head->data; }
הגדרת המבנה typedef struct dlink{ int data; struct dlink * next; struct dlink * prev; }dlink;
הוספת חוליה void insert. After 1 (dlink *where, dlink *new. Link){ new. Link->next=where->next; new. Link->prev=where; if (where->next!=NULL){ where->next->prev=new. Link; } where->next=new. Link; }
מחיקת חוליה dlink *remove. Link 1(dlink *head, dlink *to. Remove){ if (to. Remove->next != NULL) to. Remove->next->prev = to. Remove->prev; if (to. Remove->prev != NULL) to. Remove->prev->next = to. Remove->next; else head=to. Remove->next; free(to. Remove); return head; }
- Typedef struct node
- Typedef struct tree int info struct *left
- Typedef struct tree int info struct *left
- Struct node int data struct node* next
- Sum0
- Typedef struct node int value
- Typedef node
- Nodenext
- Int max(int x int y)
- Inheritance calculator
- Public void drawsquare(int x, int y, int len)
- Public int divide(int a int b)
- X.next = x.next.next
- Typedef struct c
- Typedef
- Typedef struct node node
- Typedef struct node
- Typedef struct
- Typedef struct node
- Typedef struct