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

الكل مطلووووووووووووووووووووووووووووووووووب

مغلق
بدأه linked list في 21 ديسمبر 2002 · 2 رد · 360 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

مساء الخير

ويا مرحبا فيكم

بصراحه عندي هالبرنامج

لكن دوخني حيل

لي فتره وانا ماني قادر اعدل واصحح الخطاء

فياليت تساعدوني في اسرع وقت ممكن

==============================================

#include

#include

#include

#include

class Node

{

private:

double data;

Node *next;

public:

Node( double input_data )

{

 next = NULL;

 data = input_data;

}

~Node()

{

    delete [] next;

}

bool setData(double input_data)

{

 data = input_data;

 return true;

}

double getData()

{

 return data;

}

bool setNext(Node *input_node)

{

 next = input_node;

 return true;

}

Node *getNext()

{

 return next;

}

};

class Stack

{

  private:

   Node *top;

  public:

 Stack()

 {

  top = NULL;

 }

 ~Stack()

 {

  Node *current = top, *previous;

 

  // loop to delete the nodes from stack

  while (current !=NULL)      

  {

   

   previous= current->getNext();

   delete current;

   current=previous;

  }

  top= NULL;

 }

bool isEmpty()

{

  return top == NULL;  

}

bool push(Node *n)

{

 if (n != NULL)

 {

 

  if (top == NULL)

     {

        top = n;

  }

  else

  {

                top->setNext(n);

   top = n;

   return true;

  }

 }

  return false;

}

Node *pop()

{

 Node *current = top;

 Node *old;

   

 if (top != NULL)

 {

  old = top;

  top = top->getNext();

  return old;

 

 }

 return NULL;

}

void print()

{

 Node *current=top;

 cout << "nStack Contents:" << endl;  

 if (top == NULL)

  cout<<"is empty"<

 else

 {

 if (top != NULL)

  {

   cout<< "             " <getData()<

      top->getNext();

  }

 }

}

};

double calculate(double x, double y, char *operation)

{

if (!strcmp(operation, "+"))

 return x + y;

else if (!strcmp(operation, "-"))

 return x - y;

else if (!strcmp(operation, "*"))

 return x * y;

else if (!strcmp(operation, "/"))

 return x / y;

else if (!strcmp(operation, "^"))

 return pow(x, y);

else if (!strcmp(operation, "%"))

 return (int) x % (int) y;

return -1;

}

void main()

{

Stack stack;

Node n1(10), n2(20);

char line[200], *word;

while ( (cout << "Enter a line: " << flush) && fgets(line, 200, stdin) != NULL )

{

 line[ strlen(line) - 1 ] = '

#2

لو وضعت أهداف البرنامج لكان أسهل في التصحيح ..

#3

البرنامج

عمله يجري العمليات الحسابيه + - * /

ويخزنها في الاستاك

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

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

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

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

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

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