1 package olymp;
2
3 public class PrintSelf {
4 public static String[] sourceLines = {
5 "package olymp;",
6 "",
7 "public class PrintSelf {",
8 " public static String[] sourceLines = {",
9 "[REPLACE IT]",
10 " };",
11 " private final static String slashes = \"\\\\\\\\\";",
12 " private final static String quot = \"\\\"\";",
13 " private final static String pre = \" \"+quot;",
14 " private final static String post = quot+\",\";",
15 " public static void main(String[] args) {",
16 " for (int lineIndex = 0; lineIndex < sourceLines.length; lineIndex++) {",
17 " if (\"[REPLACE IT]\".equals(sourceLines[lineIndex])) {",
18 " for (int lineSubIndex = 0; lineSubIndex < sourceLines.length; lineSubIndex++) {",
19 " System.out.println(pre+sourceLines[lineSubIndex].replaceAll(slashes,slashes+slashes).replaceAll(quot,slashes+quot)+post);",
20 " }",
21 " } else {",
22 " System.out.println(sourceLines[lineIndex]);",
23 " }",
24 " }",
25 " }",
26 "}",
27 };
28 private final static String slashes = "\\\\";
29 private final static String quot = "\"";
30 private final static String pre = " "+quot;
31 private final static String post = quot+",";
32 public static void main(String[] args) {
33 for (int lineIndex = 0; lineIndex < sourceLines.length; lineIndex++) {
34 if ("[REPLACE IT]".equals(sourceLines[lineIndex])) {
35 for (int lineSubIndex = 0; lineSubIndex < sourceLines.length; lineSubIndex++) {
36 System.out.println(pre+sourceLines[lineSubIndex].replaceAll(slashes,slashes+slashes).replaceAll(quot,slashes+quot)+post);
37 }
38 } else {
39 System.out.println(sourceLines[lineIndex]);
40 }
41 }
42 }
43 }
44
2004-04-21
Java Quine
Subscribe to:
Posts (Atom)