#14629: 求救!!(Java)


peter020104 (Peter)

學校 : 國立彰化高級中學
編號 : 70417
來源 : [112.78.82.88]
最後登入時間 :
2021-05-26 09:09:41
a022. 迴文 | From: [114.35.88.93] | 發表日期 : 2018-07-26 21:07


public class P {

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

while (sc.hasNext()) {
String s1 = sc.nextLine();
String s2 = "";
for (int i = (s1.length()); i >= 1; i--) {
s2 += s1.substring(i);
}
boolean a = s1.equals(s2);
if (a) {
System.out.println("yes");
} else {
System.out.println("no");
}

}

}

}

 
#14630: Re:求救!!(Java)


asnewchien@gmail.com (david)

學校 : 不指定學校
編號 : 68108
來源 : [114.42.180.252]
最後登入時間 :
2024-05-17 15:04:41
a022. 迴文 | From: [61.223.41.13] | 發表日期 : 2018-07-26 21:15


public class P {

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

while (sc.hasNext()) {
String s1 = sc.nextLine();
String s2 = "";
for (int i = (s1.length()); i >= 1; i--) {
s2 += s1.substring(i);
}
boolean a = s1.equals(s2);
if (a) {
System.out.println("yes");
} else {
System.out.println("no");
}

}

}

}


你的 s1.substring(i)

 
ZeroJudge Forum