import java.util.Scanner;
public class Demo2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
String[] sp = line.split(" ");
if (sp[1] == "?") {
sp[1] = "\\?";
}
// System.out.println(sp[1]);
String[] sp1 = sp[0].split(sp[1]);
int size = Integer.parseInt(sp[sp.length - 1]);
if (size > sp1.length) {
System.out.println(-1);
return;
} else {
System.out.println(sp1[Integer.parseInt(sp[sp.length - 1]) - 1]);
}
}
}
样例输入:AAA?BBB?CCC? ? 2
输出:BBB
上面的代码错在哪里? |
|