بســم الله الـرحمــن الرحيــم
السلام عليكــم ورحمـة الله وبركاتــه
المحاولات اللي عندي عملت الستاك والكيوو ولكن استخدامها في الكلينت هو المشكلة والستاك هو
- char const MAX_ITEMS=5;
- typedef int ItemType;
- class FullStack{};
- class EmptyStack{};
- class StackType{
- public:
- StackType();
- bool IsEmpty() const;
- bool IsFull() const;
- void Push(ItemType item);
- void Pop(ItemType&);
- private:
- int top;
- ItemType items[MAX_ITEMS];
- };
- StackType::StackType(){
- top = -1;
- }
- bool StackType::IsEmpty() const
- {
- return (top == -1);
- }
- bool StackType::IsFull() const
- {
- return (top == MAX_ITEMS-1);
- }
- void StackType::Push(ItemType newItem){
- if(IsFull())
- throw FullStack();
- top++;
- items[top] = newItem;
- }
- void StackType::Pop(ItemType& item){
- if(IsEmpty())
- throw EmptyStack();
- item= items[top];
- top--;
- }
- والكيو هو
- char const MAX_ITEMS=5;
- typedef char ItemType;
- class FullQue
- {
- };
- class EmptyQue
- {
- };
- class QueType
- {
- public:
- QueType();
- bool IsEmpty()const;
- bool IsFull()const;
- void EnQue(ItemType item);
- void DeQue(ItemType item);
- private:
- int front,rear;
- ItemType items[MAX_ITEMS];
- };
- QueType::QueType()
- {
- front=MAX_ITEMS-1;
- back=MAX_ITEMS-1;
- }
- bool QueType::IsEmpty() const
- {
- return(back==front);
- }
- bool QueType::IsFull() const
- {
- return(((back+1)% MAX_ITEMS)==front);
- }
- void QueType::EnQue(ItemType NewItem)
- {
- if(IsFull())
- throw FullQue();
- else
- {
- back=(back+1)% MAX_ITEMS;
- items[back]=NewItem;
- }
- }
- void QueType::DeQue(ItemType item)
- {
- if(IsEmpty())
- throw EmptyQue();
- else
- {
- front=(front+1)%MAX_ITEMS;
- item=items[front];
- }
- }
هذا اللي بدوا فيه مع انه حاسة اني ماعملوا شي
وشكرا بس انا بدي بطريقة شرحكم لانها بجد بتريحني
شكرا لاهتمامكم
تحياتي

