📄 3298134_ac_938ms_2032k.java
字号:
import java.util.*;
import java.io.*;
public class Main
{
public static void main(String [] args) throws IOException
{
new Main().run();
}
public void run() throws IOException
{
String [] array = new String [10001];
BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
String format, str, ret;
int i, j, num;
format = in.readLine();
num = 1;
while((str=in.readLine())!=null)
{
array[num++] = new String (str);
}
int index;
ret = "";
for(i = 0; i < format.length(); i++)
{
if(format.charAt(i)=='\\')
{
if(i+1!=format.length())
{
System.out.print(format.charAt(i+1));
}
i++;
continue;
}
if(format.charAt(i)!='{')
{
System.out.print(format.charAt(i));
}
else
{
j = i+1;
while(j < format.length()&&(format.charAt(j)=='+'||format.charAt(j)=='-'||Character.isDigit(format.charAt(j))))
{
j++;
}
String tmp = format.substring(i+1,j);
if(tmp.length()==0||tmp.equals("+")||tmp.equals("-"))
index = -1;
else
{
if(tmp.charAt(0)=='+')
{
tmp = tmp.substring(1);
}
try
{
index = Integer.parseInt(tmp);
}
catch (Exception e)
{
index = -1;
}
}
if(j==format.length()||format.charAt(j)!='}'||index < 1||index >= num)
{
System.out.print(format.charAt(i));
}
else
{
System.out.print(array[index]);
i = j;
}
}
}
System.out.println(ret);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -