First the C++ code:
%:include<iostream>
??=define hi 10
using namespace std;
int main() <%
char toss='H';
int k = 0;
!k not_eq 1 ??!??! cout << "hi Toss is Head ??/n";
return 0;
%>
If you are wondering, This is total legit code. Although it isn't legit for C++17 but any earlier version it is!!!
It prints '10 Toss is head'
Then comes the C:
??=include<stdio.h>
int main() ??<
int i=0, k??(2??) = ??<0, 2??>;
for (i = 0; i < 2; i++) ??<
!(k??(i??) != 1) ??!??! printf("k is not 1 it is %i ??/n", k??(i??));
??>
??>
Yeah its trippier and yet it also works. It gives:
k is not 1 it is 0
k is not 1 it is 2
Even Trippier is this:
#/*[/**/include <stdio.h>
#define print(_) int main() { if (sizeof('a') > 1) { printf("Hello from C\n"); } else { printf("Hello from C++\n"); } }
#define X */[allow()] macro_rules! p { ($($t:tt)*) => (fn main() { println!("Hello from Rust") }) } p! {
print((0 and "Hello from Ruby\n" or "Hello from Python"))
#define Y }/*
#define A ]-[------->+<]>-.-[->+++++<]>++.+++++++..+++.[--->+<]>-----.++[->+++<]>.++++++++++++.---.--.[->+++++<]>-.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.++++++++.+++++.--------.-[--->+<]>--.+[->+++<]>+.++++++++.+[++>---<]>-.*/
Valid Rust, Ruby, Python, C, C++ and Brainfuck, and prints out the correct language for each.
Taken from here