#include<iostream.h>
struct LinkedList {
int data;
struct LinkedList *badi;
};
void printList(const struct LinkedList *sar)
{
cout << "list = ";
while (sar!=NULL) {
cout << sar->data << " ";
sar = sar->badi;
}
cout << endl;
}
void main ()
{
struct LinkedList *sar=NULL, *temp, *jadid, *dovvom;
printList(sar);
// slide 1, dorost kardane liste se taayi
temp = new struct LinkedList;
temp->data = 14;
sar = temp;
temp = new struct LinkedList;
temp->data=23;
sar -> badi = temp;
temp->badi = new struct LinkedList;
temp->badi->data = 98;
temp->badi->badi = NULL;
printList(sar);
printList(sar->badi);
// slide #2, ezaafe kardane onsore 56
jadid = new struct LinkedList;
jadid->data = 56;
jadid->badi = sar;
sar = jadid;
printList(sar);
}