Implement a HQ9+ interpreter or compiler.
Basically the same as the C example, although this has been C++’ified with strings and streams.
void runCode(string code)
int c_len = code.length();
int accumulator, bottles;
cout << code << endl;
cout << "Hello, world!" << endl;
//Nice bottles song alg. from RC :)
bottles = 99;
cout << bottles << " bottles of beer on the wall" << endl;
cout << bottles << " bottles of beer" << endl;
cout << "Take one down, pass it around" << endl;
cout << --bottles << " bottles of beer on the wall" << endl << endl;
} while( bottles > 0 );
//Am I the only one finding this one weird? :o
Content is available under GNU Free Documentation License 1.2.