求优化代码

P1000 超级玛丽游戏

taoyi20110328 @ 2023-08-01 10:53:30

做出来了,感觉可以优化但不会。有大佬优化吗?


by yzm0325 @ 2023-08-01 10:55:21

@taoyi20110328 直接输出


by yzm0325 @ 2023-08-01 10:55:40

如果真要优化可以用 PHP(笑


by lg4927618350 @ 2023-08-01 10:55:43

你代码呢?


by taoyi20110328 @ 2023-08-01 10:55:47

#include<bits/stdc++.h>
using namespace std;
int main()
{
    cout<<"                ********"<<endl;
    cout<<"               ************"<<endl;
    cout<<"               ####....#."<<endl;
    cout<<"             #..###.....##...."<<endl;
    cout<<"             ###.......######              ###            ###"<<endl;
    cout<<"                ...........               #...#          #...#"<<endl;
    cout<<"               ##*#######                 #.#.#          #.#.#"<<endl;
    cout<<"            ####*******######             #.#.#          #.#.#"<<endl;
    cout<<"           ...#***.****.*###....          #...#          #...#"<<endl;
    cout<<"           ....**********##.....           ###            ###"<<endl;
    cout<<"           ....****    *****...."<<endl;
    cout<<"             ####        ####"<<endl;
    cout<<"           ######        ######"<<endl;
    cout<<"##############################################################"<<endl;
    cout<<"#...#......#.##...#......#.##...#......#.##------------------#"<<endl;
    cout<<"###########################################------------------#"<<endl;
    cout<<"#..#....#....##..#....#....##..#....#....#####################"<<endl;
    cout<<"##########################################    #----------#"<<endl;
    cout<<"#.....#......##.....#......##.....#......#    #----------#"<<endl;
    cout<<"##########################################    #----------#"<<endl;
    cout<<"#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#"<<endl;
    cout<<"##########################################    ############"<<endl;
    return 0;
}

by lg4927618350 @ 2023-08-01 10:56:31

你是指什么方面的优化


by Rieman_sum @ 2023-08-01 10:56:44

@taoyi20110328 看题解啊


by Rieman_sum @ 2023-08-01 10:57:10

@taoyi20110328 行数优化吗

对方是刚注册的,别说那么高级


by taoyi20110328 @ 2023-08-01 10:58:27

@zym0325 直接输出是唯一方法? 那这题太没意思了吧


by denominator @ 2023-08-01 10:58:57

#include <bits/stdc++.h>
int main () {
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('\n');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
    putchar ('*');
...
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar (' ');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('#');
    putchar ('\n');
    return 0;
}

源代码


by yzm0325 @ 2023-08-01 11:00:41

@taoyi20110328 是的呢,但是可以用 PHP 直接把那个图案粘贴上去


| 下一页