using System;
public class Program
{
public static bool Palindrom(Queue<int> q)
Queue<int> j = new Queue<int>();
Queue<int> copy = new Queue<int>();
int count = 0;
while(!q.IsEmpty())
count++;
j.Insert(q.Head());
copy.Insert(q.Remove());
}
if(count==0) // אם התור ריק הוא פלינדרום
return true ;
if(count == 1) // אם בתור יש רק מספר אחד הוא פלינדרום
q.Insert(j.Remove());
for(int i=0;i < count-1;i++) // להחזיר לקיו את כולם חוץ מהאחרון
if(q.Head()!=j.Head()) // אם הראשון והאחרון לא שווים
return false;
// אם הראשון והאחרון שווים
j.Insert(q.Remove());
if(Palindrom(q))
while(!copy.IsEmpty())
q.Insert(copy.Remove());
return true;
else