السلام عليكم ورحمة الله وبركاته
اخباركم إيش عاملين
عندي طلب صغير
كتبت كود لاراي اتعامل معاها علي انها ستاك
طول الاراي كان ثابت ودحين ابغاه يكون مدخل من اليوزر كيف ؟؟
هذا هو الكود
header file
وهنا عرف الكلاس إلي فيه الدوال إلي راح اعملها في الستاك
class StackType{public:StackType();void MakeEmpty();bool IsEmpty () const ; // ·„ ÷⁄Ì «·«fiÊ«”bool IsFull () const ; // ·„ ÷⁄Ì «·«fiÊ«”void Push( int item);void Pop (int & item);void DisplayStack();private:int top;int items[10];};وهذا ملف ثاني كتبت فيه الآكواد حقت الدوال#include <iostream>#include"StackType.h"using namespace std;StackType::StackType(){top=-1;}void StackType::MakeEmpty(){top=-1;}bool StackType::IsEmpty() const{return (top==-1);}bool StackType::IsFull() const{return (top==9);}void StackType::Push(int newItem){top++;items[top]=newItem;}void StackType::Pop(int& item){item=items[top];top--;}void StackType::DisplayStack(){cout<<"top-->";for(int i=top;i>=0;i--)cout<<"\t|\t" <<items <<"\t|" <<endl;cout<<"\t|-----------------|"<<endl;}وهذا هو المين#include <iostream>#include"StackType.h"//#include"StackType.cpp"using namespace std;int main(){StackType r;int size;cout<<"please enter number of elements you want to be less than 10" <<"\n";cin>>size;int temp=0;for(int i=1; i<=size;i++){cout<<"enter the element number "<<i<<" to push into the stack \n";cin>>temp;r.Push(temp);cout<<endl;}cout<<"display the elaments of the stack: ";r.DisplayStack();int key;cout<<endl<<" pop the elements from the stack : "<<endl;while(!r.IsEmpty()){r.Pop(key);cout<<" "<<key<<"is removed from stack"<<endl;}cout<<endl<<" push 7 and then 6 into the stack \n";r.Push(7);r.Push(6);cout<<endl<<"display the elements of the stack\n";r.DisplayStack();cout<<endl<<" Make the stack empty \n"<<endl;r.MakeEmpty();cout<<endl<<"check whether the stack is empty\n"<<endl;if(r.IsEmpty())cout<<"the stack is empty\n";elsecout<<"the stack isn't empty\n";return 0;}دحين ابغا اخلي المصفوفه
int items طولها مدخل من المستخدم حاول اني اكتب التالي
int x;
int items[x] ; cin >> x ;
لكن للاسف مو راضي ياريت لو تساعدوني

