LİSTEYE DÜĞÜM YOLUYLA ELEMAN EKLEME

BAĞLI LİSTEYE DÜĞÜMLERİ EKLEYELİM VE AŞAĞIDA DA BUNU GERÇEKLEYEN C++ KODU BULUNMAKTADIR

#include<conio.h>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>

using namespace std;
struct Node{

char data;
struct Node *next;
};
struct Liste{

int count;
struct Node *head;
struct Node *last;
}liste;

void ekle(char);
void yaz();
main()
{
char s[]=”MEHMETSALIHDEVECI”;
liste.count=0;
liste.head=NULL;
liste.last=NULL;

for(int i=0;i<strlen(s);i++)
ekle(s[i]);

yaz();

int x;cin>>x;
}
void ekle(char datal)
{
struct Node *pnew=new struct Node;

pnew->data=datal;

if(liste.head==NULL){
pnew->next=NULL;
liste.head=pnew;
liste.last=pnew;

}

else{
pnew->next=NULL;
liste.last->next=pnew;
liste.last=pnew;
}

liste.count++;

}

void yaz()
{
struct Node *p;

p=liste.head;

while(p->next!=NULL){

cout<<p->data;
p=p->next;
} cout<<p->data;
}

MEHMET SALİH DEVECİ

BİLGİSAYAR MÜHENDİSİ

 

Leave a Reply

Your email address will not be published. Required fields are marked *