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

هذا برنامجي ارجوا المساعده في تكميل البرنامج

بدأه كن مع الله في 4 يونيو 2009 · 9 رد · 687 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكــم ورحمـة الله وبركاتـه

رجاءا انا بدي اكمل باقى الاوامر ارجواالمساعده وارجوا اكتشاف شو الخطا

هادا البرنامج

#include<string>
#include<iostream>
#include<conio.h>
using namespace ::std;
struct node
{
    int number;
    node *next;

};
typedef node *node_ptr;  // to use program easily
         // prototype functions
   //*********************************************************************

  node_ptr make_new_node(node_ptr &first,int x);
void display_list(node_ptr first );
void create_nodes(node_ptr &first,int n);
void order_insert(node_ptr &first,int x);
void insert_begin(node_ptr &first);
void insert_last(node_ptr &first);
void delete_first(node_ptr &first);
void delete_last(node_ptr &first);
int  count_alist(void);
void sortALL(void);
void invert(void);
void concatenate(void);


//************************************************************************
void main() {
              //declarations
            //************
  node_ptr first;

  first=NULL;
  char choose;
  int n;

  cout<<"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\n"
       <<"\t*  >>>NAME:                                              *\n"
       <<"\t*                                                        *\n"
       <<"\t*  >>                                                    *\n"
       <<"\t*                                                        *\n"
       <<"\t*  >>                                                   *\n"
  <<"\t\t\n*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n";

 

  done:
    cout<<"\n\n\t\t WHAT DO YOU WANT TO DO ??\n\n"
        <<"\t*******************************************\n"
        <<"\t*\t  1-  create alist                    *\n"
        <<"\t*\t  2-  display list                    *\n"
        <<"\t*\t  3-  insert_first                    *\n"
        <<"\t*\t  4-  insert_position                 *\n"
        <<"\t*\t  5-  insert_end                      *\n"
        <<"\t*\t  6-  delete_first                    *\n"
        <<"\t*\t  7-  delete_position                 *\n"
        <<"\t*\t  8-  delete_end                      *\n"
        <<"\t*\t  9-  count alist                     *\n"
        <<"\t*\t  10- sort alist                      *\n"
        <<"\t*\t  11_concaterate list                 *\n"
        <<"\t*\t  12-  exit from application          *\n"
        <<"\t*******************************************\n";

        cin>>choose;
        switch(choose) {

        case'1':
        cout<<"\t Enter numbre of nodes to create\n";
        cin>>n;
        create_nodes(first,n);
        goto done;
          break;

        case'2':
        display_list(first);
        goto done;
         break;

        case'3':
        insert_begin(first);
        goto done;
         break;

        case'4':
        insert_last(first);
        goto done;
          break;


        case'5':
        delete_begin(first);
        goto done;
         break ;

        case'6':
        delete_last(first);
        goto done;
         break ;

          case'7':
        count_last;
        goto done;
         break;

        case'8':
        sort- nodes(List);
        goto done;
        break;

        case'9':
        concaterate_nodes(List);
        goto done;
         break;

            default:

            char continuo;
           retry:

                       cout<<"are you sure you want to exit (y / n )\n";
            cin>> continuo;
            if(continuo=='n')
            {
                goto done;
            }
            else if(continuo=='y')
            {

            }

                          else
            {
                cout<<"you are not press acorrect botton,please Retry do\n";
                goto retry;
            }
            break;
    }
}


                                         // functions
                                     //-------------------
    // TO MAKE anew node
    //*********************

node_ptr make_new_node(int x)
{
     node_ptr p;
     p=new node;
     p->number =x;
     p->next =NULL;
     return p;
}

   // TO display anodes
// **********************
void display_list(node_ptr first )
{
    node_ptr p;
    if(first==NULL)
        cout<<"NO, nodes founds>>>";
    else
    {
        cout<<"\t The Data in the nodes are   :\n";
        p=first;
        while(p!=NULL)
        {
            cout<<"value of node ---> ";
            cout<<p->number <<endl;
            p=p->next;
        }
    }

      //      TO CREATE lists of nodes
//     **************************** 

void create_nodes(node_ptr &first,int n)

{
    int x;
    cout<<"\t\t enter the data in nodes\n";
    for(int i=1;i<=n;i++)
    {
        cout<<" node # "<<i<<endl;
        cin>>x;
        order_insert(first,x);
    }
}

//               Order insert
     //*********************************
void order_insert(node_ptr &first,int x)
{
    node_ptr p;
    if(first==NULL)
    {
        first=make_new_node (x);
    }
    else if(x==first->number )
    {
        cout<<"\t This value in node is Exist \n";
    }
    else if(x<first->number )
    {
        p=make_new_node (x);
        p->next =first;
        first=p;
    }
    else
        order_insert(first->next ,x);
}

//     Insert in the Begining
// **************************
void insert_begin(node_ptr &first)
{
    int x;
    cout<<"enter value in new node\n";
    cin>>x;
    node_ptr p;
    p=make_new_node(x);
    p->next=first;
    first=p;
}

//    Insert in the last
//   ************************
void insert_last(node_ptr &first)
{
    int x;
    cout<<"entr value in new node \n";
    cin>>x;
    node_ptr p,q;
    if(first==NULL)
    {
    first=make_new_node (x);
    }
    else
    {
    p=first;
    while(p->next!=NULL)
    {
        p=p->next ;
    }
    q=make_new_node (x);
    p->next =q;
    }
}

//           TO delete first node
//   ******************************************

void delete_first(node_ptr &first)
{
    if(first==NULL)
    {
        cout<<"NO,nodes found .....\n";
    }
    else
    {
    node_ptr p;
    p=first;
    first=first->next;
    delete p;
    }
}


//          TO delete last
//        *****************
void delete_last (node_ptr &first)
{
    if(first==NULL)
        cout<<" NO;nodes found......\n";
    else if (first->next ==NULL)
        delete first;
    else
        delete_last (first->next );

 

 

        getchar();
        };
palestine1.gif
#2

السلام عليكم

البرنامج الآن بدون أخطاء ان شاء الله

باقى 3 دوال لم يتم كتابتها

#include<string>
#include<iostream>
#include<conio.h>
using namespace ::std;
struct node
{
int number;
node *next;

};
typedef node *node_ptr; // to use program easily
// prototype functions
//*********************************************************************

node_ptr make_new_node(node_ptr &first,int x);
void display_list(node_ptr first );
void create_nodes(node_ptr &first,int n);
void order_insert(node_ptr &first,int x);
void insert_begin(node_ptr &first);
void insert_last(node_ptr &first);
void delete_first(node_ptr &first);
void delete_last(node_ptr &first);
int count_alist(void);
void sortALL(void);
void invert(void);
void concatenate(void);


//************************************************************************
void main() {
//declarations
//************
node_ptr first;

first=NULL;
char choose;
int n;

cout<<"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\n"
<<"\t* >>>NAME: *\n"
<<"\t* *\n"
<<"\t* >> *\n"
<<"\t* *\n"
<<"\t* >> *\n"
<<"\t\t\n*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n";

done:
cout<<"\n\n\t\t WHAT DO YOU WANT TO DO ??\n\n"
<<"\t*******************************************\n"
<<"\t*\t 1- create alist *\n"
<<"\t*\t 2- display list *\n"
<<"\t*\t 3- insert_first *\n"
<<"\t*\t 4- insert_position *\n"
<<"\t*\t 5- insert_end *\n"
<<"\t*\t 6- delete_first *\n"
<<"\t*\t 7- delete_position *\n"
<<"\t*\t 8- delete_end *\n"
<<"\t*\t 9- count alist *\n"
<<"\t*\t 10- sort alist *\n"
<<"\t*\t 11_concaterate list *\n"
<<"\t*\t 12- exit from application *\n"
<<"\t*******************************************\n";

cin>>choose;
switch(choose) {

case'1':
cout<<"\t Enter numbre of nodes to create\n";
cin>>n;
create_nodes(first,n);
goto done;
break;

case'2':
display_list(first);
goto done;
break;

case'3':
insert_begin(first);
goto done;
break;

case'4':
insert_last(first);
goto done;
break;


case'5':
delete_first(first);
goto done;
break;

case'6':
delete_last(first);
goto done;
break;

case'7':
//count_alist();
goto done;
break;

case'8':
//sortALL();
goto done;
break;

case'9':
//concatenate();
goto done;
break;

default:

char continuo;
retry:

cout<<"are you sure you want to exit (y / n )\n";
cin>> continuo;
if(continuo=='n')
{
goto done;
}
else if(continuo=='y')
{

}

else
{
cout<<"you are not press acorrect botton,please Retry do\n";
goto retry;
}
break;
}
}


// functions
//-------------------
// TO MAKE anew node
//*********************

node_ptr make_new_node(int x)
{
node_ptr p;
p=new node;
p->number =x;
p->next =NULL;
return p;
}

// TO display anodes
// **********************
void display_list(node_ptr first )
{
node_ptr p;
if(first==NULL)
cout<<"NO, nodes founds>>>";
else
{
cout<<"\t The Data in the nodes are :\n";
p=first;
while(p!=NULL)
{
cout<<"value of node ---> ";
cout<<p->number <<endl;
p=p->next;
}
}
}
// TO CREATE lists of nodes
// ****************************

void create_nodes(node_ptr &first,int n)

{
int x;
cout<<"\t\t enter the data in nodes\n";
for(int i=1;i<=n;i++)
{
cout<<" node # "<<i<<endl;
cin>>x;
order_insert(first,x);
}
}

// Order insert
//*********************************
void order_insert(node_ptr &first,int x)
{
node_ptr p;
if(first==NULL)
{
first=make_new_node (x);
}
else if(x==first->number )
{
cout<<"\t This value in node is Exist \n";
}
else if(x<first->number )
{
p=make_new_node (x);
p->next =first;
first=p;
}
else
order_insert(first->next ,x);
}

// Insert in the Begining
// **************************
void insert_begin(node_ptr &first)
{
int x;
cout<<"enter value in new node\n";
cin>>x;
node_ptr p;
p=make_new_node(x);
p->next=first;
first=p;
}

// Insert in the last
// ************************
void insert_last(node_ptr &first)
{
int x;
cout<<"entr value in new node \n";
cin>>x;
node_ptr p,q;
if(first==NULL)
{
first=make_new_node (x);
}
else
{
p=first;
while(p->next!=NULL)
{
p=p->next;
}
q=make_new_node (x);
p->next =q;
}
}

// TO delete first node
// ******************************************

void delete_first(node_ptr &first)
{
if(first==NULL)
{
cout<<"NO,nodes found .....\n";
}
else
{
node_ptr p;
p=first;
first=first->next;
delete p;
}
}


// TO delete last
// *****************
void delete_last (node_ptr &first)
{
if(first==NULL)
cout<<" NO;nodes found......\n";
else if (first->next ==NULL)
delete first;
else
delete_last (first->next );
getchar();
};

بالتوفيق

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#3

السلام عليكــم ورحمـة الله وبركاتــه ،،

شكراً لك اخي الكريم

كتير

بس اللي بعرف الدوال رجاءا يكتبهم

لكم جزيل الشكر

palestine1.gif
#4

رجارالب

palestine1.gif
#5

يا اخواني رجاءا ساعدوني

palestine1.gif
#6

السلام عليكم

دالتى count_list , delete_position

// TO count a list
//*******************
int count_alist(node_ptr first)
{
	int n=0;
	node_ptr p=first;
	while (p->next!=NULL)
	{
		n++;
		p=p->next;
	}
	return n;
}
// To delete pos
void delete_position(node_ptr& first,int pos)
{
	int n=count_alist(first);
		if(pos<=n){

	node_ptr p=first,q;
	if(pos==1) delete_first(first);
	else if(pos==n) delete_last(first);
	else
	{
		for (int i=1;i<pos-1;i++)
		{
			p=p->next;
		}
		q=p->next;
		p->next=q->next;
		delete q;
	}
		}
		else cout<<" error !!"<<endl;
}

طبعا يجب تعديل الإحتمالات فى switch فى الداله main

باقى دالتان sortalist concateratelist حاول معهم

تحياتى

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#7

شكرا كتير

بس دالة الحذف صحيحة وشكرا

واتمنى الباقى يارب

palestine1.gif
#8

شو لازم اجعل الاحتمال في

جملة swith لانه بقولي في خطا

اتمنى مساعدتي بالباق

palestine1.gif
#9

السلام عليكم

راجع القائمه الموجوده فى الداله main

وقارنها مع حالات case

وبالنسبه للداله count_alist يجب استخدام cout قبلها !!!!

cout<<count_alist(first);

بالنسبه للباقى حاول أخى ولو خطأ

سلام

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#10

شكرا اخى بس انا لو انى عارفة اعمل الدوال الباقى كان ما طلبت المساعدة ولذلك اتمنى مساعدتي

تحياتي للجميع

palestine1.gif

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…