المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : حل برنامج بواسطة ++C للمسائلة Double circular linked list


المقيمي
05-10-2009, 03:01 PM
#include<iostream>
using namespace std;
struct employee
{
int emp_id;
float emp_salary;
struct employee * llink;
struct employee * rlink;
};
void main()
{
struct employee n,*temp,*a,*t,*sort,*sortow;
char ch='y';
int count='0' ,i='0';
int j,h,id,num;
float salary;
n.rlink=NULL;
n.llink=NULL;
temp=&n;
sort=&n;
t=&n;
while(ch=='y')
{
a=(employee *)malloc(sizeof(employee));
cout<<"Enter the ID:::";
cin>>a->emp_id;
cout<<"Enter the Salary:::";
cin>>a->emp_salary;
a->llink=NULL;
a->rlink=NULL;
t->llink=a;
a->rlink=t;
t=t->llink;
cout<<"Want to continue(y/n)::";
cin>>ch;
}
cout<<"The elements in the forward traversal is(L to R)::"<<endl;
temp=temp->llink;
t->llink=temp;
temp->rlink=t;
sort=temp;
num=i;
for (j=0;j<num;j++)
{
sortow=sort->llink;
for(h=0;h<j;h++)
{
if (sort->emp_id <sortow->emp_id)
{ id=sort->emp_id ;
salary=sort->emp_salary ;
sort->emp_id =sortow->emp_id ;
sort->emp_salary =sortow->emp_salary ;
sortow->emp_id =id;
sortow->emp_salary =salary;
sortow=sortow->llink ;
}
}
sort=sort->llink;
}
while(count!=i+10)
{
cout<<temp->emp_id <<"\t";
cout<<temp->emp_salary<<endl;
temp=temp->llink;
count++;
}
cout<<"The elements in the reverse traversal is(R to L)::"<<endl;
count='0';
while(count!=i+10)
{
cout<<t->emp_id<<"\t";
cout<<t->emp_salary<<endl;
t=t->rlink;
count++;
}
}

m28ss
05-10-2009, 05:57 PM
يعطيك العافيه والله يجزاك بالخير ,,

لكن ياريت توضح أكثر عن ماهية هذه الرموز ,,

و موفق بإذن الله ,,

و ننتظر جديدكـ ,,

زهرة البراري
05-12-2009, 07:08 PM
جزاك الله خير بس وضحلنا ايش يسوي البرنامج بالضبط


وشكرا

المقيمي
05-16-2009, 04:18 PM
شكرا على الاهتمام بالموضوع والبرنامج بالفة ++c يقوم البرنامج بطباعة الارقام التي تم إدخالها من المبرمج على شكل قائمة متسلسلة ولكن هنا يقوم البرنامج بتشغيل قائمتين في نفس الوقت ويقوم بتكرار الارقام عشر مرات ويمكن تغير عدد التكرار على حسب الرغبة :)