P를 출력하는 프로그램 P
char* me; void main(void) {printf(me); putchar(13); putchar(34); printf(me); putchar(34); putchar(‘;’);} char* me =
“char* me; void main(void) {printf(me); putchar(13); puchar(34); printf(me); putchar(34); putchar(‘;’);} char* me=“;
|
public class SelfPrintProgram { public static void main(String[] args) { char q = 34; String[] codeLines = { "public class SelfPrintProgram {", " public static void main(String[] args) {", " char q = 34;", " String[] codeLines = {", " ", " };", "", " for (int i = 0; i < 4; i++) {", " System.out.println(codeLines[i]);", " }", " for (int i = 0; i < codeLines.length; i++) {", " System.out.println(codeLines[4] + q + codeLines[i] + q + ',');", " }", " for (int i = 5; i< codeLines.length; i++) {", " System.out.println(codeLines[i]);", " }", " }", "}", }; for (int i = 0; i < 4; i++) { System.out.println(codeLines[i]); } for (int i = 0; i < codeLines.length; i++) { System.out.println(codeLines[4] + q + codeLines[i] + q + ','); } for (int i = 5; i< codeLines.length; i++) { System.out.println(codeLines[i]); } } } |
참고