[C++] Interesting example of C++ code obfuscation
Recently a friend of mine has given me a piece of code in C++: puts(&3["abcdef"]);puts(&3["abcdef"]); At first glance it seems to not compile at all. But not only it compiles, but also prints “def”.
Recently a friend of mine has given me a piece of code in C++: puts(&3["abcdef"]);puts(&3["abcdef"]); At first glance it seems to not compile at all. But not only it compiles, but also prints “def”.
You can get further information about entropy here. Here is code of my program entropy.cpp:
You can check your program using command: valgrind your_programvalgrind your_program Example of usage: We have following C++ program (tst.cpp): int main() { int * tab = new int[1000000]; return 0; }int main() { int * tab = new int[1000000]; return 0; } Obviously it generates memory leak. We compile it to tst file and execute: valgrind tstvalgrind tst
Here is a list of websites, which are sets of algorithmical tasks or online contests: http://www.topcoder.com http://www.spoj.pl http://icpcres.ecs.baylor.edu/onlinejudge/ http://acm.timus.ru http://acm.mipt.ru/judge http://www.uwp.edu/sws/usaco/ http://acm.sgu.ru/ http://projecteuler.net/