Site icon IT Tutorial

C/C++ BAĞLI LİSTENİN ELEMANLARINI GÖSTERME

ŞİMDİDE BAĞLI LİSTEDE BULUNAN ELEMANLARI GÖRMEYE GELDİ AŞAĞIDAKİ KODDA İPLEMENTATİON KODLARI BULUNMAKTADIR…

#include<iostream>
using namespace std;

class Dugum{
      public:
             Dugum();
             int data;
             Dugum *Next;
            };
Dugum::Dugum()
{
     data=0;
     Next=NULL;         
             
}

class Linked_list{
             public:    
             Linked_list();
             void print();

             
             private:
                int counter;
                Dugum *head;              
                  };
Linked_list::Linked_list()
{
   counter=0;                      
   head=NULL;                      
}            

void Linked_list::print()
{
     Dugum *p1=head;    
    
     while(p1->Next!=NULL)
     {
      cout<<p1->data<<”  “;                   
      p1=p1->Next;                   
                         
     }
     cout<<endl;
    
}

main()
{
      Linked_list L;
      L.print();      
     
system (“pause”);     
}

MEHMET SALİH DEVECİ

YAZILIM MÜHENDİSİ

Exit mobile version