如何用C/C++、python打印超级玛丽
相信你看完,会有收获!
// 打印方法:常用的多行字符串写法
关于多行字符串写法的解释,举个例子来做阐述:
例如下面这样:
#include<stdio.h> int main() { printf("line 1\n" "line 2\n" "line 3\n" "line 4\n" "line 5\n" "line ...\n"); return 0; }
C:
#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" ); return 0; }
C++:
#include<iostream> using namespace std; int main() { cout<< " ********\endl" " ************\endl" " ####....#.\endl" " #..###.....##....\endl" " ###.......######\endl" " ...........\endl" " ##*#######\endl" " ####*******######\endl" " ...#***.****.*###....\endl" " ....**********##.....\endl" " ....**** *****....\endl" " #### ####\endl" " ###### ######\endl" "##########################################\endl" "#...#......#.##...#......#.##...#......#.#\endl" "##########################################\endl" "##########################################\endl" "#...#......#.##...#......#.##...#......#.#\endl" "##########################################\endl"; return 0; }
python3:
print(""" ******** ************ ####....#. #..###.....##.... ###.......###### ........... ##*####### ####*******###### ...#***.****.*###.... ....**********##..... ....**** *****.... #### #### ###### ###### ########################################## #...#......#.##...#......#.##...#......#.# ########################################## ########################################## #...#......#.##...#......#.##...#......#.# ##########################################""")
希望这篇文章对你有所帮助!
作者:Code_流苏
创作不易,喜欢的话,还请多多点赞与关注!
感谢支持!欢迎评论交流学习!