Mustaqil ish Mavzu: Chiziqli ikki bog’lamli ro’yxatlar va ularni dasturda amalga oshirish Bajardi: Sobirov U. Guruh: tt2M21-01 Mavzu: Chiziqli ikki bog’lamli ro’yxatlar va ularni dasturda amalga oshirish Reja
return; } // display linked list contents void
Download 341.5 Kb.
|
return;
} // display linked list contents void displayList(struct Node *node) { //traverse the list to display each node while (node != NULL) { cout< node = node->next; } if(node== NULL) cout<<"null"; } /* main program for linked list*/ int main() { /* empty list */ struct Node* head = NULL; // Insert 10. append(&head, 10); // Insert 20 at the beginning. push(&head, 20); // Insert 30 at the beginning. push(&head, 30); // Insert 40 at the end. append(&head, 40); // Insert 50, after 20. insertAfter(head->next, 50); cout<<"Final linked list: "< return 0; } Chiqish: Yakuniy bog'langan ro'yxat: 30–>20–>50–>10–>40–>null Keyinchalik, Java-da bog'langan ro'yxatni kiritish operatsiyasini amalga oshiramiz. Java tilida bog'langan ro'yxat sinf sifatida amalga oshiriladi. Quyidagi dastur mantiqan C++ dasturiga o'xshaydi, yagona farq shundaki, biz bog'langan ro'yxat uchun sinfdan foydalanamiz.
Download 341.5 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling