Information Technology "IT" - level 4
500 subscribers
688 photos
40 videos
834 files
170 links
رابط قناة المراجع والملخصات والنماذج والمحاضرات
@Al_Adeeb_Group
Download Telegram
الخميس القادم اختبار MIS نهائي
المحاضرات الداخلة في الاختبار:
1
2
5
6
7
8
9
تنبيه ⭕️ :
الي مايكتب اسمه او يغيب عن الامتحان يحرم من الامتحان النهائي النظري .
Forwarded from ❥͢ ❈↡< C++ > برمجة (❥ツ)
إ₰👨🏻‍💻👩🏻‍💻₰❥

عملية الاتحاد union لعناصر قائمتين احادية single linked lists :-

#include <iostream>
using namespace std;
class list
{
public:
struct Node
{
int data;
Node *next;
};
Node *head = NULL;
Node *counter = NULL;

void insert(int value)
{
Node *newnode = new Node();
newnode->data = value;
newnode->next = NULL;

if (head == NULL)
{
head = counter = newnode;
return;
}
else
{
Node *temp = head;
while (temp->next != NULL)
{
temp = temp->next;
}

temp->next = newnode;
}
}


void display_elements()
{
Node *temp = head;
while (temp != NULL)
{
cout << temp->data << "\t";
temp = temp->next;
}
}
};


void find_union(list l1, list l2)
{
bool found = false;
list union_elements;
union_elements = l2;
while (l1.counter != NULL)
{
while (union_elements.counter != NULL)
{
if (l1.counter->data == union_elements.counter->data)
{
found = true;
break;
}
union_elements.counter = union_elements.counter->next;
}
if (found == 0)
union_elements.insert(l1.counter->data);
union_elements.counter = union_elements.head;
l1.counter = l1.counter->next;
found = 0;
}
union_elements.display_elements();
cout << endl;
cout << "----------------------------------------" << endl;
}
int main()
{
list ls, lis;
ls.insert(2);
ls.insert(5);
ls.insert(3);
ls.insert(9);
cout << "----------------------------------------" << endl;
cout << "this the first linkedlist" << endl;
cout << endl;
ls.display_elements();
cout << endl;
lis.insert(5);
lis.insert(3);
lis.insert(7);
cout << "----------------------------------------" << endl;
cout << "this the second linkedlist" << endl;
cout << endl;
lis.display_elements();
cout << endl;
cout << "----------------------------------------" << endl;
cout << "this the union of tow linkedlists" << endl;
cout << endl;
find_union(ls, lis);
}


•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja
•┈┈┈•❈••✦✾✦••❈•┈┈┈•


المخـ₰💻₰❥ـرجات


----------------------------------------
this the first linkedlist
2 5 3 9
----------------------------------------
this the second linkedlist
5 3 7
----------------------------------------
this the union of tow linkedlists
5 3 7 2 9
--------------------------------------
[Program finished]