📄 checkpalindrome.java
字号:
public class CheckPalindrome
{
public static boolean isPalindrome(Stack s, Queue q)
{
while (!s.isEmpty())
{
try
{
Character c1 = (Character) s.pop();
Character c2 = (Character) q.dequeue();
if (! (c1.equals(c2)))
{
return false;
}
}
catch (StackException se)
{
System.err.println(se);
}
catch (QueueException qe)
{
System.err.println(qe);
}
}
return true;
}
public static void main(String args[])
{
Stack stack = new Stack();
Queue queue = new Queue();
System.out.print("Enter string: ");
String string = Console.readString();
for (int i = 0; i < string.length(); i++)
{
queue.enqueue(new Character(string.charAt(i)));
stack.push(new Character(string.charAt(i)));
}
System.out.println("Palindrome: " + isPalindrome(stack, queue));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -