#12640: Java AC


zga1218 (unknown)

學校 : 不指定學校
編號 : 68214
來源 : [118.166.236.107]
最後登入時間 :
2017-09-15 20:48:16
a022. 迴文 | From: [1.169.19.73] | 發表日期 : 2017-08-31 11:57

import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class ReturnString {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

while (sc.hasNext()) {
String s = sc.nextLine();
char[] c = s.toCharArray();
Deque<Character> deque = new LinkedList<>();
boolean status = true;
for (int i = 0; i < c.length; i++) {
deque.push(c[i]);
}
for (int i = 0; i < c.length; i++) {
if (c[i] != deque.pollFirst()) {
status = false;
System.out.println("no");
break;
}
}
if (status) {
System.out.println("yes");
}
}
}
}

 
ZeroJudge Forum