const char *id = "Andrey Mirtchovski, 358764"; char s[] = {32,32,32,32,32,32,32,47,42,10,32,9,42,32,67,111,109,112,117,116,101,114,32,83,99,105,101,110,99,101,32,51,52,48,44,32,97,115,115,105,103,110,109,101,110,116,32,49,10,9,42,10,9,42,32,80,117,115,112,111,115,101,58,32,119,105,116,104,111,117,116,32,97,110,121,32,105,110,112,117,116,44,32,112,114,105,110,116,32,116,104,101,32,99,111,110,116,101,110,116,115,32,111,102,32,116,104,101,32,10,9,42,32,115,111,117,114,99,101,32,99,111,100,101,32,111,102,32,116,104,105,115,32,112,114,111,103,114,97,109,46,10,9,42,10,9,42,32,68,105,115,99,108,97,105,109,101,114,58,10,9,42,32,84,104,101,32,105,100,101,97,32,102,111,114,32,116,104,105,115,32,112,97,114,116,105,99,117,108,97,114,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,32,10,9,42,32,119,97,115,32,116,97,107,101,110,32,102,114,111,109,32,75,101,110,32,84,104,111,109,112,115,111,110,39,115,32,97,114,116,105,99,108,101,32,10,9,42,32,34,82,101,102,108,101,99,116,105,111,110,115,32,111,110,32,116,114,117,115,116,105,110,103,32,116,114,117,115,116,34,32,40,97,118,97,105,108,97,98,108,101,32,111,110,32,116,104,101,32,110,101,116,41,46,10,9,42,32,84,104,101,32,111,114,105,103,105,110,97,108,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,32,100,105,100,32,110,111,116,32,114,101,115,117,108,116,32,105,110,32,49,48,48,37,32,99,111,114,114,101,99,116,10,9,42,32,111,117,116,112,117,116,32,111,102,32,116,104,101,32,99,111,100,101,44,32,115,111,32,73,32,104,97,100,32,116,111,32,99,104,97,110,103,101,32,105,116,32,97,32,98,105,116,44,32,115,111,32,116,104,101,32,99,111,100,101,10,9,42,32,105,115,32,101,110,116,105,114,101,108,121,32,119,114,105,116,116,101,110,32,98,121,32,109,101,44,32,104,111,119,101,118,101,114,32,116,104,101,32,105,100,101,97,32,105,115,32,110,111,116,32,109,105,110,101,46,10,9,42,32,77,97,121,98,101,32,116,104,105,115,32,99,111,117,108,100,32,98,101,32,114,101,102,101,114,114,101,100,32,97,115,32,97,32,98,117,103,102,105,120,32,111,102,32,116,104,101,32,111,114,105,103,105,110,97,108,32,112,114,111,103,114,97,109,44,10,9,42,32,119,105,116,104,32,97,32,108,105,116,116,108,101,32,98,105,116,32,111,102,32,114,101,100,101,115,105,103,110,105,110,103,46,10,9,42,10,9,42,32,65,99,116,117,97,108,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,58,32,84,104,101,32,118,97,114,105,97,98,108,101,32,34,115,34,32,99,111,110,116,97,105,110,115,32,116,104,101,32,10,9,42,32,101,110,116,105,114,101,32,98,111,100,121,32,111,102,32,116,104,101,32,112,114,111,103,114,97,109,32,40,102,114,111,109,32,34,47,42,34,32,116,111,32,34,101,120,105,116,32,48,59,92,110,125,34,41,32,116,111,103,101,116,104,101,114,10,9,42,32,119,105,116,104,32,119,104,105,116,101,115,112,97,99,101,32,99,104,97,114,97,99,116,101,115,32,40,108,105,110,101,32,98,114,101,97,107,115,44,32,116,97,98,115,41,46,32,84,104,105,115,32,118,97,114,105,97,98,108,101,32,105,115,10,9,42,32,100,101,102,105,110,101,100,32,97,116,32,116,104,101,32,116,111,112,32,111,102,32,116,104,101,32,99,111,100,101,32,98,108,111,99,107,44,32,104,111,119,101,118,101,114,32,116,104,101,32,99,104,97,114,97,99,116,101,114,115,10,9,42,32,97,114,101,32,103,105,118,101,110,32,105,110,32,100,101,99,105,109,97,108,32,105,110,32,111,114,100,101,114,32,116,111,32,101,115,99,97,112,101,32,103,101,116,116,105,110,103,32,99,97,117,103,104,116,32,105,110,32,101,115,99,97,112,101,10,9,42,32,115,101,113,117,101,110,99,101,32,114,101,99,117,114,115,105,111,110,115,46,10,9,42,32,84,104,105,115,32,118,97,114,105,97,98,108,101,32,105,115,32,112,114,105,110,116,101,100,32,99,104,97,114,97,99,116,101,114,32,98,121,32,99,104,97,114,97,99,116,101,114,32,40,97,103,97,105,110,32,105,110,32,10,9,42,32,100,101,99,105,109,97,108,41,32,97,116,32,116,104,101,32,98,101,103,105,110,110,105,110,103,32,111,102,32,116,104,101,32,111,117,116,112,117,116,44,32,105,110,32,111,114,100,101,114,32,116,111,32,101,109,117,108,97,116,101,10,9,42,32,116,104,101,32,100,101,102,105,110,105,116,105,111,110,32,111,102,32,116,104,101,32,118,97,114,105,97,98,108,101,32,105,116,115,101,108,102,46,32,65,102,116,101,114,32,116,104,101,32,108,97,115,116,32,99,104,97,114,97,99,116,101,114,32,10,9,42,32,116,104,101,32,118,97,114,105,97,98,108,101,32,105,115,32,112,114,105,110,116,101,100,32,97,103,97,105,110,32,40,97,115,32,97,32,115,116,114,105,110,103,41,32,116,111,32,101,109,117,108,97,116,101,32,116,104,101,32,98,111,100,121,10,9,42,32,111,102,32,116,104,101,32,112,114,111,103,114,97,109,46,10,9,42,10,9,42,32,84,111,32,114,101,99,101,105,118,101,32,116,104,101,32,99,111,100,101,32,111,102,32,116,104,101,32,112,114,111,103,114,97,109,32,105,110,32,100,101,99,105,109,97,108,32,99,104,97,114,97,99,116,101,114,115,32,10,9,42,32,97,110,111,116,104,101,114,32,112,114,111,103,114,97,109,32,119,97,115,32,117,115,101,100,44,32,119,104,105,99,104,32,114,101,97,100,32,116,104,101,32,115,111,117,114,99,101,32,99,111,100,101,32,102,105,108,101,32,97,110,100,10,9,42,32,111,117,116,112,117,116,116,101,100,32,116,104,101,32,105,110,116,101,103,101,114,115,32,99,111,114,114,101,115,112,111,110,100,105,110,103,32,116,111,32,101,97,99,104,32,99,104,97,114,97,99,116,101,114,32,40,105,110,99,108,117,100,105,110,103,41,10,9,42,32,119,104,105,116,101,115,112,97,99,101,46,32,10,9,42,10,9,42,32,80,111,114,116,97,98,105,108,105,116,121,58,32,84,104,105,115,32,112,114,111,103,114,97,109,32,105,115,32,112,111,114,116,97,98,108,101,32,97,109,111,110,103,32,110,111,110,45,87,105,110,100,111,119,115,32,79,83,39,115,32,97,115,32,10,9,42,32,108,111,110,103,32,97,115,32,116,104,101,121,32,100,111,32,110,111,116,32,117,115,101,32,116,104,101,32,34,92,110,92,114,34,32,101,110,100,32,111,102,32,108,105,110,101,32,115,101,113,117,101,110,99,101,46,32,73,116,32,99,97,110,10,9,42,32,115,116,105,108,108,32,98,101,32,115,117,99,99,101,115,115,102,117,108,121,32,99,111,109,112,105,108,101,100,32,97,110,100,32,114,97,110,32,111,110,32,119,105,110,100,111,119,115,44,32,104,111,119,101,118,101,114,32,10,9,42,32,116,104,101,32,111,117,116,112,117,116,32,115,104,111,117,108,100,32,110,111,116,32,98,101,32,114,101,97,100,32,119,105,116,104,32,110,111,116,101,112,97,100,32,40,110,111,116,101,112,97,100,32,110,101,101,100,115,32,34,92,110,92,114,34,10,9,42,32,116,111,32,119,114,97,112,32,116,104,101,32,108,105,110,101,41,46,32,10,9,42,32,10,32,9,42,47,10,35,105,110,99,108,117,100,101,32,60,105,111,115,116,114,101,97,109,62,32,10,35,105,110,99,108,117,100,101,32,60,99,115,116,100,105,111,62,10,109,97,105,110,40,41,32,123,32,10,9,105,110,116,32,105,59,32,10,9,99,111,117,116,32,60,60,32,34,99,111,110,115,116,32,99,104,97,114,32,42,105,100,32,61,32,92,34,65,110,100,114,101,121,32,77,105,114,116,99,104,111,118,115,107,105,44,32,51,53,56,55,54,52,92,34,59,92,110,34,59,10,9,99,111,117,116,32,60,60,32,34,99,104,97,114,32,115,91,93,32,61,32,123,34,59,32,10,9,102,111,114,40,105,61,48,59,32,115,91,105,43,49,93,59,32,105,43,43,41,32,10,9,9,112,114,105,110,116,102,40,34,37,100,44,34,44,115,91,105,93,41,59,32,10,9,112,114,105,110,116,102,40,34,37,100,34,44,32,115,91,105,93,41,59,10,9,99,111,117,116,32,60,60,34,125,59,92,110,34,59,10,9,99,111,117,116,32,60,60,32,115,59,32,10,9,101,120,105,116,32,40,48,41,59,10,125,10}; /* * Computer Science 340, assignment 1 * * Puspose: without any input, print the contents of the * source code of this program. * * Disclaimer: * The idea for this particular implementation * was taken from Ken Thompson's article * "Reflections on trusting trust" (available on the net). * The original implementation did not result in 100% correct * output of the code, so I had to change it a bit, so the code * is entirely written by me, however the idea is not mine. * Maybe this could be referred as a bugfix of the original program, * with a little bit of redesigning. * * Actual implementation: The variable "s" contains the * entire body of the program (from "/*" to "exit 0;\n}") together * with whitespace charactes (line breaks, tabs). This variable is * defined at the top of the code block, however the characters * are given in decimal in order to escape getting caught in escape * sequence recursions. * This variable is printed character by character (again in * decimal) at the beginning of the output, in order to emulate * the definition of the variable itself. After the last character * the variable is printed again (as a string) to emulate the body * of the program. * * To receive the code of the program in decimal characters * another program was used, which read the source code file and * outputted the integers corresponding to each character (including) * whitespace. * * Portability: This program is portable among non-Windows OS's as * long as they do not use the "\n\r" end of line sequence. It can * still be successfuly compiled and ran on windows, however * the output should not be read with notepad (notepad needs "\n\r" * to wrap the line). * */ #include #include main() { int i; cout << "const char *id = \"Andrey Mirtchovski, 358764\";\n"; cout << "char s[] = {"; for(i=0; s[i+1]; i++) printf("%d,",s[i]); printf("%d", s[i]); cout <<"};\n"; cout << s; exit (0); }