请问这个code生成印度地图? [英] How does this code generate the map of India?

查看:137
本文介绍了请问这个code生成印度地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这code打印印度的地图。它是如何工作的?

 的#include<&stdio.h中GT;
主要()
{
    诠释A,B,C;
    诠释计数= 1;
    对于(B = C = 10; A = - 图?UMKC,XYZHello伙计们,\\
    TFY!QJu ROO TNN(ROO)SLQ SLQ ULO + \\
    UHS UJq TNN *的RPn / QPbEWS_JSWQAIJO ^ \\
    NBELPeHBFHT} TnALVlBLOFAkHFOuFETp \\
    HCStHAUFAgcEAelclcn ^ R ^ R \\\\ tZvYxXy \\
    T | S〜光合SPM儿子TNN ULo0ULo#ULO-W \\
    !HQ WFS XDT[B +++ 21];!)
    对于(; A--> 64;)
    的putchar(++ç=='Z'C = C / 9:33 ^ B和1);
    返回0;
}


解决方案

长字符串仅仅是转换成ASCII二进制序列。第一个语句使 B 10开始的,而 [B +++ 21] 字符串收率31处理字符串作为一个阵列中后,偏移量31是该串中的真正的数据的开始(你提供的code样品中的第二行) 。的code的其余部分只是通过比特序列循环,转换1和0的对!的和空白并打印一个字符时间

减模糊版本:

 的#includestdio.h中
诠释主要(无效){
    诠释一个= 10时,b = 0,C = 10;
    字符*位=TFY QJu ROO TNN(ROO)SLQ SLQ ULO + UHS UJq TNN *的RPn / QPbEWS_JSWQAIJO ^ NBELPeHBFHT} TnALVlBLOFAkHFOuFETpHCStHAUFAgcEAelclcn ^ R ^ R \\\\ tZvYxXyT!| S〜光合SPM儿子TNN ULo0ULo#ULO-WHQ WFS XDT !;
    一个=比特并[b]
    而(一个!= 0){
        一个=比特并[b]
        基础B ++;
        而(A> 64){
            一个 - ;
            如果(++ç=='Z'){
                C / = 9;
                的putchar(C);
            }其他{
                的putchar(33 ^(B&安培; 0×01));
            }
        }
    }
    返回0;
}

的<击>奇怪巧妙的部分是在的putchar 语句。先取的putchar 。 ASCII 'Z' 90是十进制,所以90/9 = 10是一个换行符。第二,十进制33是 ASCII'!。切换的33低位给你32,这是一个空间ASCII。这将导致来,如果打印b 是奇数,如果乙是偶数。在code的其余部分是来这里只是为了走指针 A 通过字符串。

This code prints the map of India. How does it work?

#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;
}

解决方案

The long string is simply a binary sequence converted to ASCII. The first for statement makes b start out at 10, and the [b+++21] after the string yields 31. Treating the string as an array, offset 31 is the start of the "real" data in the string (the second line in the code sample you provided). The rest of the code simply loops through the bit sequence, converting the 1's and 0's to !'s and whitespace and printing one character at a time.

Less obfuscated version:

#include "stdio.h"
int main (void) {
    int a=10, b=0, c=10;
    char* bits ="TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBLOFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";
    a = bits[b];
    while (a != 0) {
        a = bits[b];
        b++;
        while (a > 64) {
            a--;
            if (++c == 'Z') {
                c /= 9;
                putchar(c);
            } else {
                putchar(33 ^ (b & 0x01));
            }
        }
    }
    return 0;
}

The strange clever part is in the putchar statements. Take the first putchar. ASCII 'Z' is 90 in decimal, so 90 / 9 = 10 which is a newline character. In the second, decimal 33 is ASCII for '!'. Toggling the low-order bit of 33 gives you 32, which is ASCII for a space. This causes ! to be printed if b is odd, and a blank space to be printed if b is even. The rest of the code is simply there to walk the "pointer" a through the string.

这篇关于请问这个code生成印度地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆