الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

برنامج سي

مغلق
بدأه saleh2006 في 3 يوليو 2007 · 1 رد · 508 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

#include<iostream.h>

//////////////////////

typedef struct nodetype

{

int info;

nodetype *next;

}node;

/////////////////////////////////////

void display(nodetype *list)

{

while(list!=NULL)

{

cout<<list->info;

list =list->next;

}

}

/////////////////////////////////////////////

nodetype *delet (nodetype *list,int x)

{

int y;

nodetype *p ,*q;

p=list;

cin>>y;

if(p->info==x)

{

list =list->next;

delete p;

return list;

}

else

while(p !=NULL)

{

if(p->info==x)

{

q->next=p->next;

delete p;

break ;

}

q=p;

p=p->next;

return list;

}

}

//////////////////////////

void main()

{

int x;

cin>>x;

nodetype *head ,*p ,*q ;

head = new(node);

head ->info=x;

head ->next=NULL;

//////////////////////////

p=head;

for(int i=0;i<=3;i++)

{

cin>>x;

q=new(node);

q->info=x;

q->next=NULL;

p->next=q;

p=q;

}

display(head);

head=delet(head,x);

cout<<endl;

display(head);

}//end main

//////////////////////////////

get-3-2007-e5fkurgs.jpg
#2

اولا رتب الكود هكذا!!!

#include<iostream.h>
//////////////////////
typedef struct nodetype
{
int info;
nodetype *next;
}node;
/////////////////////////////////////
void display(nodetype *list)
{
while(list!=NULL)
{
cout<<list->info;
list =list->next;
}
}
/////////////////////////////////////////////
nodetype *delet (nodetype *list,int x)
{
int y;
nodetype *p ,*q;
p=list;
cin>>y;
if(p->info==x)
{
list =list->next;
delete p;
return list;

}
else
while(p !=NULL)
{
if(p->info==x)
{
q->next=p->next;
delete p;

break;
}
q=p;
p=p->next;
return list;
}
}
//////////////////////////
void main()
{
int x;
cin>>x;
nodetype *head ,*p ,*q;
head = new(node);
head ->info=x;
head ->next=NULL;

//////////////////////////
p=head;
for(int i=0;i<=3;i++)
{ 
cin>>x;
q=new(node);
q->info=x;
q->next=NULL;
p->next=q;
p=q;
}
display(head);
head=delet(head,x);
cout<<endl;
display(head);

}//end main
//////////////////////////////

هذا برنامج يعرف تركيب قائمة (نوع من المصفوفات)

لديه اجراءان واحد لعرض محتوي التركيب

والاخر لحزفه كما يتيح ادخال عناصر القائمة

( _ /)

(='.'=)

(")-(")

هذا الموضوع مغلق.

مواضيع مشابهة