#include <conio.h>
#include <iostream>
#include "stackarr.cpp"
#include "queuearr.h"
main()
{
using namespace std;
Stack<char> stack(20);
QueType<char> queue(20);
char ch;
//read the potential palindrome
cout << "Enter a phrase terminated by carriage return: ";
cin.get(ch);
//put the elements on a stack and queue
int i=0;
while (ch != '\n')
{
stack.push(ch);
queue.Enqueue(ch);
cin.get(ch);
}
//remove elements and compare them
bool palindrome = true;
char stackElem;
char queueElem;
while (!stack.isEmpty() && palindrome) {
stack.pop();
queue.Dequeue();
palindrome = (stackElem==queueElem);
}
//print results
if (palindrome)
cout << "It is a palindrome\n";
else
cout << "It is not a palindrome\n";
return 0;
getch ();
}هذا البرنامج يقوم على ادخال جملة ويختبر هل هي تقرأمن الطرفين ام لا ؟؟
السؤال//هل هذا صحيح؟ واذا كان كذلك لماذا لا يعطي نتائج صحيحة؟
مع العلم أن الملفين
"stackarr.h"
"queuearr.h"
صحيحين 100/100
/////////////////////////////////////////
سؤال آخر // مامعنى
cin.get(ch);