1987 International C Language Chaos Code competition winning line of code

Source: Internet
Author: User


MACB ()?

Lpcbyu (&gbcq/_\021%ocq\012\0_=w (GBCQ)/_dak._=}_ugb_[0q60) s+


This is the Coolshell Bo master before doing a very interesting online puzzle, imitate some front-end clearance of the game, do a few and program ape-related puzzles, a clearance game. The second question of the test. And for the top 10 of customs clearance to send the "UNIX Environment Advanced Programming (Third Edition)"(thank

From=feed&loc=at "style=" color: #6c6351 ">@ Publishing Circle Guo Zhimin Sponsorship" or a mug (thanks to the @linux command line featured network sponsorship)) These puzzles are very interesting at the same time also have some difficulty. Because of the limited level, I did not customs clearance. But I feel like these things are really interesting and worth doing. Can learn a lot of things from it.

This is the original game Test link http://fun.coolshell.cn/.

I think this test is quite interesting. Just go in to see the page on the wrong start AH. Limited to personal ability and narrow knowledge, at the author's prompt to understand that this is a Brainfuck programming language related fields. After searching the web for information, the answer is "welcome.html".

A detailed solution to the implementation process see brainfuck--make your mind messy programming language




When I saw this keyboard, I found it was different from our usual keyboard layout. So I thought, the problem is to replace the characters of the keyboard with the characters in the corresponding position on our computer keyboard. So I did it very quickly. Results such as the following

Main () {printf (&unix["\021%six\012\0"], (Unix) ["has"]+ "fun" -0x60);}
see here a little dumbfounded, this is the legendary C language confusion code. This is the 4th International obfuscated C Code Contest (1987), by the T-Bell LabsWritten by David Korn.

Previous International C Language Chaos Code contest works appreciated . Paste the code into the IDE after you copy it. Compile Hint "Unixwas not declared in thisscope".

Well, there's no statement. That's decisive. Define a value with a # define macro

#define UNIX 1
The result is UNIX.

The result is really not the intention, Chaos code is a word "chaos" of the have.

By viewing the relevant information. Finally, I figured out what it really was.


First review a little knowledge:

Character-type constants and ASCII character sets. Each character occupies a byte in memory and is used to store its ASCII code value. So. C-language characters have numeric characteristics. Can participate in operations like integers.

Escape characters: Some characters, such as carriage return (' \ R '), and other control symbols such as line breaks (' \ n '), are not displayed on the screen. Also cannot be entered from the keyboard, only can be represented by an escape character. The escape character consists of a backslash plus a character or number, which converts the character or number after the backslash to something else.

\DDD the        characters represented by the 1-3-bit octal character, such as \102= ' B '    \xhh        1-2-bit hexadecimal characters. such as \x41= ' A '
printf ("%x", ' \ n ');p rintf ("%x", ' \ R ');//Line break. The ASCII value of the carriage return is a,d, which is 10 of the decimal. 13
last. It's a very important point .
int a[3]={1,2,3};p rintf ("%d%d\n", a[2], 2[a]);//Yes, your eyes are not mistaken. He's actually outputting the 3</span>.
The above from the "C and the Hands",arry[2] and 2[arry]Is equivalent, this strange trick is feasible, derived from the C language implementation of the following table method.

Although there is no difference between the two, there is no doubt that this affects the readability of the program. Do not recommend large-scale promotion caused unnecessary kill!

See here, we can convert the above translated code once again, such as the following:

Main () {printf (&unix["\021%six\n"], (Unix) ["has"]+ "fun" -0x60);} The \021=17,ascii character is DC1. It is a character; \012=10=0xa= ' \ n ', \0= ' 0 '. Then main () {printf (& "Dc1%six\n\0" [Unix], "has" [unix]+ "Fun" -0x60);} Make unix=1. Then main () {printf (& "dc1%six\n" [1], "has" [1]+ "Fun" -0x60);} & "dc1%six\n", go to the address at subscript 1 in the string, then main () {printf ("%six\n", ' A ' -0x60+ "fun");} The ASCII of a is only 97=0x61, then main () {printf ("%six\n", "fun" + 1);} The above equals main () {printf ("%six\n", "un");}
write it down here. The whole process should be very clear and clear.

OK, then look at the next question.



1987 International C Language Chaos Code competition winning line of code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.