当前位置:   article > 正文

永远的“超级玛丽游戏”(洛谷)_python超级玛丽代码 洛谷

python超级玛丽代码 洛谷

最近闲的蛋疼,来科普一道非常困难 简单的题目:超级玛丽游戏。不知道是哪个SB 大佬出的题目,打的我手都快废了,啊啊啊啊啊,下面,让我们来认真的学习一下这道题目。

先发个福利:超级玛丽

解法1:

#include<stdio.h>
int main() {
    printf(
    "                ********\n"
    "               ************\n"
    "               ####....#.\n"
    "             #..###.....##....\n"
    "             ###.......######              ###            ###\n"
    "                ...........               #...#          #...#\n"
    "               ##*#######                 #.#.#          #.#.#\n"
    "            ####*******######             #.#.#          #.#.#\n"
    "           ...#***.****.*###....          #...#          #...#\n"
    "           ....**********##.....           ###            ###\n"
    "           ....****    *****....\n"
    "             ####        ####\n"
    "           ######        ######\n"
    "##############################################################\n"
    "#...#......#.##...#......#.##...#......#.##------------------#\n"
    "###########################################------------------#\n"
    "#..#....#....##..#....#....##..#....#....#####################\n"
    "##########################################    #----------#\n"
    "#.....#......##.....#......##.....#......#    #----------#\n"
    "##########################################    #----------#\n"
    "#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#\n"
    "##########################################    ############\n"
    );
    return 0;
}   //本蒟蒻手打的,虽然通过了,但是真的手快断了,cry......
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

下面来欣赏一下大佬们的优秀 鬼畜做法。
解法2:

#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;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84

解法3:

#include<iostream>
int main()
{
    std::cout<<R"(                ********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###            ###
                ...........               #...#          #...#
               ##*#######                 #.#.#          #.#.#
            ####*******######             #.#.#          #.#.#
           ...#***.****.*###....          #...#          #...#
           ....**********##.....           ###            ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
##########################################    #----------#
#.....#......##.....#......##.....#......#    #----------#
##########################################    #----------#
#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
##########################################    ############ )";
}  //这个毒瘤的大佬使用了一种神奇的技术: C++11 raw string literal 技术,让你体会复制粘贴的恐惧
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

解法4(C#):

using System;
namespace Luogu
{
    class Algo{
        public static void Main()
        {
            Console.Write(@"                ********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###            ###
                ...........               #...#          #...#
               ##*#######                 #.#.#          #.#.#
            ####*******######             #.#.#          #.#.#
           ...#***.****.*###....          #...#          #...#
           ....**********##.....           ###            ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
##########################################    #----------#
#.....#......##.....#......##.....#......#    #----------#
##########################################    #----------#
#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
##########################################    ############");
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

解法5(python):

print("""                ********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###            ###
                ...........               #...#          #...#
               ##*#######                 #.#.#          #.#.#
            ####*******######             #.#.#          #.#.#
           ...#***.****.*###....          #...#          #...#
           ....**********##.....           ###            ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
##########################################    #----------#
#.....#......##.....#......##.....#......#    #----------#
##########################################    #----------#
#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
##########################################    ############""")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

解法6(pascal):

    begin
    writeln('                ********');
    writeln('               ************');
    writeln('               ####....#.');
    writeln('             #..###.....##....');
    writeln('             ###.......######              ###            ###');
    writeln('                ...........               #...#          #...#');
    writeln('               ##*#######                 #.#.#          #.#.#');
    writeln('            ####*******######             #.#.#          #.#.#');
    writeln('           ...#***.****.*###....          #...#          #...#');
    writeln('           ....**********##.....           ###            ###');
    writeln('           ....****    *****....');
    writeln('             ####        ####');
    writeln('           ######        ######');
    writeln('##############################################################');
    writeln('#...#......#.##...#......#.##...#......#.##------------------#');
    writeln('###########################################------------------#');
    writeln('#..#....#....##..#....#....##..#....#....#####################');
    writeln('##########################################    #----------#');
    writeln('#.....#......##.....#......##.....#......#    #----------#');
    writeln('##########################################    #----------#');
    writeln('#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#');
    writeln('##########################################    ############');
end.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

解法7:

#include<stdio.h>
int main()
{
 printf("                ********\n");
 printf("               ************\n");
 printf("               ####....#.\n");
 printf("             #..###.....##....\n");
 printf("             ###.......######              ###            ###\n");
 printf("                ...........               #...#          #...#\n");
 printf("               ##*#######                 #.#.#          #.#.#\n");
 printf("            ####*******######             #.#.#          #.#.#\n");
 printf("           ...#***.****.*###....          #...#          #...#\n");
 printf("           ....**********##.....           ###            ###\n");
 printf("           ....****    *****....\n");
 printf("             ####        ####\n");
 printf("           ######        ######\n");
 printf("##############################################################\n");
 printf("#...#......#.##...#......#.##...#......#.##------------------#\n");
 printf("###########################################------------------#\n");
 printf("#..#....#....##..#....#....##..#....#....#####################\n");
 printf("##########################################    #----------#\n");
 printf("#.....#......##.....#......##.....#......#    #----------#\n");
 printf("##########################################    #----------#\n");
 printf("#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#\n");
 printf("##########################################    ############\n");
 return 0; 
} 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

解法8(PHP):

********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###            ###
                ...........               #...#          #...#
               ##*#######                 #.#.#          #.#.#
            ####*******######             #.#.#          #.#.#
           ...#***.****.*###....          #...#          #...#
           ....**********##.....           ###            ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
##########################################    #----------#
#.....#......##.....#......##.....#......#    #----------#
##########################################    #----------#
#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
##########################################    ############
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

解法9(python最短代码挑战赛):

import zlib,base64;print zlib.decompress(base64.b64decode('eJylUkEOwCAIu/sKk95Mxv+fN2AsE0S3xR42sRYqUqtHM5TJfsaBQQyQZ3jTGLp+JcqIjBUMSUMYy1Z6EB1J0hCOrhuywnoeXo4gF5U1I0nxJhc3rKSmH2vDd/Ny+nkMa6I3F7xmallrgvRh0K9L4DzLPLZQ9IY2CdekTKNjwK/qqdwK4J7TeZSa/wxtWKjc3W4VjdKdqt2tsIp2q3Y4AbV3oO4=')).decode()
  • 1

解法10(ascll版):

#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()
{
//  被我注释掉的部分是我当时拿来转换的程序
//  freopen("x.in","r",stdin);
//  freopen("x.out","w",stdout);
//  x=getchar();
//  while(x!=EOF)
//  {
//      printf("%d,",(int)x);
//      x=getchar();
//  }
    for(int i = 0;i <= 1148;i++)
    {
        cout<<(char)a[i]; 
    } 
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

解法11(pascal手打压缩):

const
  p:ansistring=' 9 3*6! 9 2*9*! 9 2#2.2#.! 9 0#.0#1.3#0.2! 9 0#1.5#4 9 1#1 9 #1! 9 3.9 9 2#.1# 8#.1#! 9 2#0*#5 9 4#.#.# 8#.#.#! 9 #2*5#4 9 0#.#.# 8#.#.#! 9.1#*1.*2.*#1.2 8#.1# 8#.1#! 9.2*8#0.3 9#1 9 #1! 9.2*2 2*3.2! 9 0#2 6#2! 9#4 6#4!#9#9#9#9#9#5!#.1#.4#.#0.1#.4#.#0.1#.4#.#0-9-5#!#9#9#9#8-9-5#!#.0#.2#.2#0.0#.2#.2#0.0#.2#.2#9#8!#9#9#9#7 2#-8#!#.3#.4#0.3#.4#0.3#.4# 2#-8#!#9#9#9#7 2#-8#!#.#.0#.2#.0#0.#.0#.2#.0#0.#.0#.2#.0# 2#-8#!#9#9#9#7 2#9#!';
var i,j:longint;
begin
  for i:=1 to length(p) do
    case p[i] of
      '0'..'9':for j:=1 to ord(p[i])-ord('0')+1 do write(p[i-1]);
      '!':writeln;
    else write(p[i])
  end
end.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

解法12(Ruby):

puts <<EOF
                ********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###            ###
                ...........               #...#          #...#
               ##*#######                 #.#.#          #.#.#
            ####*******######             #.#.#          #.#.#
           ...#***.****.*###....          #...#          #...#
           ....**********##.....           ###            ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
##########################################    #----------#
#.....#......##.....#......##.....#......#    #----------#
##########################################    #----------#
#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
##########################################    ############
EOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

好了,就这么多。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/215690
推荐阅读
相关标签
  

闽ICP备14008679号