السلام عليكم اعضاء المنتدى...
اذا تكرمتوا علي ....تعلموني وين المشكلة بكود الترتيب للــlinked list
والترتيب بــinsert sort
وهذا البرنامج:
#include <iostream.h>
struct node
{
int num;
node *next;
};
void main ()
{
int i;
node *ptr,*ptr2;
ptr=new node;
ptr->num=7;
ptr->next=NULL;
i=1;
ptr2=ptr;
cout<<"the element of linked list \n\n \n";
while(i<4)
{
ptr2->next=new node;
ptr2=ptr2->next;
cout<<"\tthe NUM :";
cin>>ptr2->num;
cout<<"\n";
ptr2->next=NULL;
i++;
}
cout<<"The element of linked list before sorting:\n\n";
ptr2=ptr;
while(ptr2!=NULL)
{
cout<<ptr2->num<<"\t";
ptr2=ptr2->next;
}
ptr2=ptr;
i=1;
while( (i<4)&&(ptr2!=NULL))
{
int temp = ptr2->next->num;
while((ptr2->num > temp) )
{ ptr2->next->num = ptr2->num;
ptr2=ptr->next;
}
ptr->num = temp;
break;
i++;
}
cout<<"\n\n";
cout<<"\n\nThe element of linked list after sorting:\n\n";
ptr2=ptr;
while(ptr2!=NULL)
{
cout<<ptr2->num<<"\t";
ptr2=ptr2->next;
}
cout<<"\n\n\n\n\n";
}وهنا الكود الي فيه مشكلة:
ptr2=ptr;
i=1;
while( (i<4)&&(ptr2!=NULL))
{
int temp = ptr2->next->num;
while((ptr2->num > temp) )
{ ptr2->next->num = ptr2->num;
ptr2=ptr->next;
}
ptr->num = temp;
break;
i++;
}واتمنى الي عنده معلومات كافية عن doubly linked list ,
,circil
يفيدني ..بايش ممكن استفيد منهم ويكونون اسهل من single
?
,,واكون شاكرة للجميع.
