• 洛谷P1000超级马里奥的神奇解法


      话说上过洛谷的都知道,有一道经典例题P1000超级马里奥,这一题,可以说是非常简单非常经典,但是就算如此,还是可以人才辈出,我是个比较循规蹈矩的人(雾),所以我的代码就比较平常,也就是直接输出了所要求的超级马里奥的图片,那道题题目是这样的

    超级玛丽是一个非常经典的游戏。请你用字符画的形式输出超级玛丽中的一个场景。

                    ********
                   ************
                   ####....#.
                 #..###.....##....
                 ###.......######              ###            ###
                    ...........               #...#          #...#
                   ##*#######                 #.#.#          #.#.#
                ####*******######             #.#.#          #.#.#
               ...#***.****.*###....          #...#          #...#
               ....**********##.....           ###            ###
               ....****    *****....
                 ####        ####
               ######        ######
    ##############################################################
    #...#......#.##...#......#.##...#......#.##------------------#
    ###########################################------------------#
    #..#....#....##..#....#....##..#....#....#####################
    ##########################################    #----------#
    #.....#......##.....#......##.....#......# #----------# ########################################## #----------# #.#..#....#..##.#..#....#..##.#..#....#..# #----------# ########################################## ############
    一般人都会写个cout+endl来实现输出的操作,但是,网友的力量是强大的,只有想不到没有做不到的,
    接下来我介绍几种 ,注意,非原创

    比如这位大佬,看之前先来一波膜拜orz,orz;
    #include <bits/stdc++.h>
    using namespace std;
    int mp[100][100];
    int last[100];
    int n = 22, m = 62;
    // 在[x1-x2, y1-y2]绘制ch
    void draw(int x1, int y1, int x2, int y2, char ch = '#'){
        for(int i = x1; i <= x2; i++)
            for(int j = y1; j <= y2; j++)
                mp[i][j] = ch;
    }
    // 在[x1, y1]绘制ch
    void draw(int x1, int y1, char ch = '#'){
        draw(x1, y1, x1, y1, ch);
    }
    // 以[x, y]为左上角绘制泥土
    void drawland(int x, int y){
        draw(x, y, x+8, y+13);
        for(int i = x+1; i < x+8; i+=2)
            draw(i, y+1, i, y+12, '.');
        draw(x+1, y+4); draw(x+1, y+11);
        draw(x+3, y+3); draw(x+3, y+8);
        draw(x+5, y+6); draw(x+7, y+2);
        draw(x+7, y+5); draw(x+7, y+10);
    }
    // 以[x, y]为左上角绘制小岛
    void drawisland(int x, int y){
        draw(x, y, x+3, y+19);
        draw(x+1, y+1, x+2, y+18, '-');
        draw(x+4, y+4, x+8, y+15);
        draw(x+4, y+5, x+7, y+14, '-');
    }
    // 以[x, y]为左上角绘制金币
    void drawcoin(int x, int y){
        draw(x, y, x+5, y+4);
        draw(x+1, y+1, x+4, y+3, '.');
        draw(x+2, y+2, x+3, y+2);
        draw(x, y, ' '); draw(x+5, y, ' ');
        draw(x, y+4, ' '); draw(x+5, y+4, ' ');
    }
    // 以[x, y]为左上角绘制马里奥
    void drawman(int x, int y){
        draw(x, y+5, x, y+12, '*'); x++;
        draw(x, y+4, x, y+15, '*'); x++;
        draw(x, y+4, x, y+7); draw(x, y+8, x, y+13, '.'); draw(x, y+12); x++;
        draw(x, y+2, x, y+14); draw(x, y+3, x, y+4, '.');
        draw(x, y+8, x, y+12, '.'); draw(x, y+15, x, y+18, '.'); x++;
        draw(x, y+2, x, y+17); draw(x, y+5, x, y+11, '.'); x++;
        draw(x, y+5, x, y+15, '.'); x++;
        draw(x, y+4, x, y+13); draw(x, y+6, '*'); x++;
        draw(x, y+1, x, y+17); draw(x, y+5, x, y+11, '*'); x++;
        draw(x, y, x+2, y+20, '.'); draw(x, y+4, x+2, y+16, '*');
        draw(x, y+3); draw(x, y+14, x+1, y+16); draw(x+1, y+16, '.');
        draw(x+2, y+8, x+2, y+11, ' '); draw(x, y+7, '.'); draw(x, y+12, '.');
        draw(x+3, y, x+4, y+19); draw(x+3, y+6, x+4, y+13, ' ');
        draw(x+3, y, x+3, y+1, ' '); draw(x+3, y+18, x+3, y+19, ' ');
    }
    // 打印输出
    void printscreen(){
        for(int i = 1; i <= n; i++){
            last[i] = m;
            while(mp[i][last[i]] == ' ')
                last[i]--;
        }
        for(int i = 1; i <= n; i++,puts(""))
            for(int j = 1; j <= last[i]; j++)
                putchar(mp[i][j]);
    }
    int main(){
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                mp[i][j] = ' ';
        // 绘制人
        drawman(1, 12);
        // 绘制他脚下的三块泥土
        drawland(14, 1); drawland(14, 15); drawland(14, 29);
        // 绘制金币下面的那个岛屿
        drawisland(14, 43);
        // 绘制两个金币
        drawcoin(5, 43); drawcoin(5, 58);
        // 输出
        printscreen();
        return 0;
    }

    大致也看完了吧,这个人,不,这位大佬以坐标的方式,一个一个的把字符输出,最后达到了一样的效果,不得不说,这也太强了吧,你也去试试吧(雾)

    如果只有这么点我也不会说是人才辈出了,下面这位可以说是暴力出奇迹了(雾)

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<climits>
    #include<cfloat>
    #include<queue>
    #include<cstddef>
    
    using namespace std;
    char x;
    int a[10000]={32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,42,42,42,42,42,42,42,42,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,42,42,42,42,42,42,42,42,42,42,42,42,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,35,35,35,35,46,46,46,46,35,46,10,32,32,32,32,32,32,32,32,32,32,32,32,32,35,46,46,35,35,35,46,46,46,46,46,35,35,46,46,46,46,10,32,32,32,32,32,32,32,32,32,32,32,32,32,35,35,35,46,46,46,46,46,46,46,35,35,35,35,35,35,32,32,32,32,32,32,32,32,32,32,32,32,32,32,35,35,35,32,32,32,32,32,32,32,32,32,32,32,32,35,35,35,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,46,46,46,46,46,46,46,46,46,46,46,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,35,46,46,46,35,32,32,32,32,32,32,32,32,32,32,35,46,46,46,35,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,35,35,42,35,35,35,35,35,35,35,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,35,46,35,46,35,32,32,32,32,32,32,32,32,32,32,35,46,35,46,35,10,32,32,32,32,32,32,32,32,32,32,32,32,35,35,35,35,42,42,42,42,42,42,42,35,35,35,35,35,35,32,32,32,32,32,32,32,32,32,32,32,32,32,35,46,35,46,35,32,32,32,32,32,32,32,32,32,32,35,46,35,46,35,10,32,32,32,32,32,32,32,32,32,32,32,46,46,46,35,42,42,42,46,42,42,42,42,46,42,35,35,35,46,46,46,46,32,32,32,32,32,32,32,32,32,32,35,46,46,46,35,32,32,32,32,32,32,32,32,32,32,35,46,46,46,35,10,32,32,32,32,32,32,32,32,32,32,32,46,46,46,46,42,42,42,42,42,42,42,42,42,42,35,35,46,46,46,46,46,32,32,32,32,32,32,32,32,32,32,32,35,35,35,32,32,32,32,32,32,32,32,32,32,32,32,35,35,35,10,32,32,32,32,32,32,32,32,32,32,32,46,46,46,46,42,42,42,42,32,32,32,32,42,42,42,42,42,46,46,46,46,10,32,32,32,32,32,32,32,32,32,32,32,32,32,35,35,35,35,32,32,32,32,32,32,32,32,35,35,35,35,10,32,32,32,32,32,32,32,32,32,32,32,35,35,35,35,35,35,32,32,32,32,32,32,32,32,35,35,35,35,35,35,10,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,10,35,46,46,46,35,46,46,46,46,46,46,35,46,35,35,46,46,46,35,46,46,46,46,46,46,35,46,35,35,46,46,46,35,46,46,46,46,46,46,35,46,35,35,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,35,10,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,35,10,35,46,46,35,46,46,46,46,35,46,46,46,46,35,35,46,46,35,46,46,46,46,35,46,46,46,46,35,35,46,46,35,46,46,46,46,35,46,46,46,46,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,10,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,32,32,32,32,35,45,45,45,45,45,45,45,45,45,45,35,10,35,46,46,46,46,46,35,46,46,46,46,46,46,35,35,46,46,46,46,46,35,46,46,46,46,46,46,35,35,46,46,46,46,46,35,46,46,46,46,46,46,35,32,32,32,32,35,45,45,45,45,45,45,45,45,45,45,35,10,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,32,32,32,32,35,45,45,45,45,45,45,45,45,45,45,35,10,35,46,35,46,46,35,46,46,46,46,35,46,46,35,35,46,35,46,46,35,46,46,46,46,35,46,46,35,35,46,35,46,46,35,46,46,46,46,35,46,46,35,32,32,32,32,35,45,45,45,45,45,45,45,45,45,45,35,10,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,32,32,32,32,35,35,35,35,35,35,35,35,35,35,35,35,10};
    int main()
    {
        for(int i = 0;i <= 1148;i++)
        {
            cout<<(char)a[i]; 
        } 
        return 0;
    }

    打表。。。

    这也未尝不是一种不错的方法,能存下所有的坐标,也是厉害所在啊%%%!这些还不够达到人才辈出,没错,还有优秀的代码优秀的人!

    接下来是优秀的人,但看他的代码没什么出众的地方,但是他的题解可以说是很有文化了,我截取他的代码的其中一段的题解

    吾有一術。名之曰「画点」。欲行是術。必先得三數。曰「甲」。曰「乙」。曰「字」。乃行是術曰。 施「画」於「甲」。於「乙」。於「甲」。於「乙」。於「字」。 是謂「画点」之術也。 吾有一術。名之曰「画地」。欲行是術。必先得二數。曰「甲」。曰「乙」。乃行是術曰。 加「甲」以八。名之曰「丙」。加「乙」以十三。名之曰「丁」。 施「画」於「甲」。於「乙」。於「丙」。於「丁」。於「井」。 吾有一列。名之曰「戊」。充「戊」以一。以三。以五。以七。 凡「戊」中之「己」。 加「己」以「甲」。名之曰「庚」。加「乙」以一。名之曰「丙」。加「乙」以十二。名之曰「丁」。 施「画」於「庚」。於「丙」。於「庚」。於「丁」。於「点」。 云云。

    #include<stdio.h>
    int main() {
        printf(
        "                ********
    "
        "               ************
    "
        "               ####....#.
    "
        "             #..###.....##....
    "
        "             ###.......######              ###            ###
    "
        "                ...........               #...#          #...#
    "
        "               ##*#######                 #.#.#          #.#.#
    "
        "            ####*******######             #.#.#          #.#.#
    "
        "           ...#***.****.*###....          #...#          #...#
    "
        "           ....**********##.....           ###            ###
    "
        "           ....****    *****....
    "
        "             ####        ####
    "
        "           ######        ######
    "
        "##############################################################
    "
        "#...#......#.##...#......#.##...#......#.##------------------#
    "
        "###########################################------------------#
    "
        "#..#....#....##..#....#....##..#....#....#####################
    "
        "##########################################    #----------#
    "
        "#.....#......##.....#......##.....#......#    #----------#
    "
        "##########################################    #----------#
    "
        "#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
    "
        "########################
     
    ##################    ############
    "
        );
        return 0;
    }

    看着题解,心里自愧不如,你说编程不比别人好也就算了,语文也被吊打。。。

    今天的内容就只有这些了,在最后,请广大博主帮我看看,这个代码是什么意思?(雾)python学的少,没见过世面(大雾)

    import zlib,base64;print zlib.decompress(base64.b64decode('eJylUkEOwCAIu/sKk95Mxv+fN2AsE0S3xR42sRYqUqtHM5TJfsaBQQyQZ3jTGLp+JcqIjBUMSUMYy1Z6EB1J0hCOrhuywnoeXo4gF5U1I0nxJhc3rKSmH2vDd/Ny+nkMa6I3F7xmallrgvRh0K9L4DzLPLZQ9IY2CdekTKNjwK/qqdwK4J7TeZSa/wxtWKjc3W4VjdKdqt2tsIp2q3Y4AbV3oO4=')).decode()
  • 相关阅读:
    Django信号机制相关解释与示例
    花了三个月终于把所有的 Python 库全部整理了!可以说很全面了
    Django3.0 异步通信初体验(小结)
    基于docker-compose搭建本地sentry服务
    权限控制终于来了!Redis 6.0新特性——ACLs
    redis为什么是单线程而且速度快?
    Notepad++ 异常崩溃 未保存的new *文件列表没了怎么办?
    Umi + Dva + Antd的React项目实践
    Windows下同时安装python2和python3如何兼容版本
    consul实现kubernetes-1.15集群master的高可用访问实现
  • 原文地址:https://www.cnblogs.com/qj-Network-Box/p/qj-firstblog1.html
Copyright © 2020-2023  润新知