0

Need clarification on how it works.

#include "stdio.h"
main()
{
    int a,b,c;
    int count = 1;
    for (b=c=10;a="- FIGURE?, UMKC,XYZHello Folks,\
        TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
        UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
        NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\
        HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\
        T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\
        Hq!WFs XDt!" [b+++21]; )

        for(; a-- > 64 ; )
            putchar ( ++c=='Z' ? c = c/ 9:33^b&1);
    return 0;
}

Try it yourself and if you know how this program prints that map, please explain me.

Miraz
  • 343
  • 3
  • 15

1 Answers1

0

Edit: Sorry, didn't see the dupe...


After removing the various unreadabilities, unnecessary and unused code and other kinds of obfuscation, the code is equivalent with this:

    #include "stdio.h"

int main()
{
    int curr_char, b, c;

    const char *data = "\
    TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
    UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
    NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\
    HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\
    T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\
    Hq!WFs XDt!";

    for (b = 0, c = 10; curr_char = data[b]; ) {
        b++;
        for(; curr_char-- > 64 ; ) {
            putchar(++c == 'Z' ? c = c / 9 : 33 ^ b & 1);
        }
    }

    return 0;
}

Basically the program stores the map data in the string (each row corresponds to 4 characters), goes over the string character by character, "decodes" it (using some maths I didn't bother to reverse engineer), then prints either a space or a '!' mark or a newline at the end of the line.