struct list *prev1, *prev2, *next1, *next2; prev1=lst1->prev; //lst1 dan oldingi tugun
prev2= st2->prev; //lst2 dan oldingi tugun
next1=lst1->next; //lst1 dan keyingi tugun
next2=lst2->next; //lst2 dan keyingi tugun
if (lst2==next1) { //qo’shni tugunlarni almashtirish
lst2->next=lst1; lst2->prev=prev1; lst1->next=next2; lst1->prev=lst2; next2->prev=lst1; prev1->next=lst2; } else if (lst1==next2) { //qo’shni tugunlarni almashtirish
lst1->next=lst2; lst1->prev=prev2; lst2->next=next1; lst2->prev=lst1; next1->prev=lst2; prev2->next=lst1; } else { //qolgan tugunlarni almashtirish
prev1->next=lst2; lst2->next=next1; prev2->next=lst1; lst1->next=next2; lst2->prev=prev1; next2->prev=lst1; lst1->prev=prev2; next1->prev=lst2; } if (lst1==head) return(lst2); if (lst2==head) return(lst1); return(head); }
Mustaqil ishlash uchun savollar: 1. Ma’lumotlar toifasi tushunchasi nima va nima uchun ma’lumotlar toifalanadi?
2. Qanday ma’lumot toifalarini bilasiz?
3. Oddiy va sozlangan toifalarni tushuntiring.
4. Struct va vector toifalarini tushuntiring.
5. Class va massivlar qanday e’lon qilinadi?
Adabiyotlar 1. [RU] Alfred V. Axo., Djon E. Xopkroft, Djefri D. Ul’man. Struktura dannыx i algoritmы. //Ucheb.pos., M.: Izd.dom: "Vil’yams", 2000, — 384 s.
2. [EN] Adam Drozdek. Data structures and algorithms in C++. Fourth edition.Cengage Learning, 2013. 3. [UZ] I.M. Boynazarov. Dinamik ma’lumotlar tuzilmasi. Uslubiy qo’llanma. -Samarqand, TATU Samarqand filiali, 2018 y. 215 bet.
4. [UZ] Narzullaev U.X., Qarshiev A.B., Boynazarov I.M. Ma’lumotlar tuzilmasi va algoritmlar. //O’quv qo’llanma. Toshkent: Tafakkur nashriyoti, 2013 y. – 192 b.
http://fayllar.org