This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
Pretty self explanatory, but there are some rules.
Rules:
I'll start off simple:
print("Hello Program!")
name = input("What is your name?")
In a spoiler because the code is long. To run you will need g++ and gcc in the system path.
def genFile(): import os code = open("code_cpp.cpp", 'w') code.write("""#include <fstream> using namespace std; string code = "def is_even(n):\\ \\n import os\\ \\n\\ \\n code_file = open(\\"is_even.c\\", 'w')\\ \\n code_file.write(\\ \\n \\"\\"\\"#include <stdio.h>\\ \\n#include <stdlib.h>\\ \\n\\ \\nint isEven(int x);\\ \\n\ \\nint main(int argc, char** argv)\\ \\n{\\ \\n //isEven(atoi(argv[1]));\\ \\n\\ \\n return isEven(atoi(argv[1]));\\ \\n}\\ \\n\\ \\nint isEven(int x)\\ \\n{\\ \\n int answer = 0;\\ \\n while (--x) answer = !answer;\\ \\n //printf(\\"%d\\", answer);\\ \\n return answer;\\ \\n}\\ \\n\\"\\"\\")\\ \\n\\ \\n code_file.close()\\ \\n\\ \\n os.system(\\"gcc -o is_even.exe is_even.c\\")\\ \\n i = os.system(\\"is_even.exe %d\\" % n)\\ \\n os.remove(\\"is_even.exe\\")\\ \\n os.remove(\\"is_even.c\\")\\ \\n return i\\ \\n\\ \\nfor i in range(100):\\ \\n print(str(i) + \\": \\" + str(bool(is_even(i))))\\ "; int main() { ofstream out; out.open("is_even.py", ios::out|ios::trunc); out << code; out.close(); return 0; } """) code.close() os.system("g++ -o code_cpp.exe code_cpp.cpp") genFile()
Pretty self explanatory, but there are some rules.
Rules:
I'll start off simple:
print("Hello Program!")
In a spoiler because the code is long. To run you will need g++ and gcc in the system path.
After my 5th attempt I finally did it