洛谷——【入门1】顺序结构

【入门1】顺序结构

声明

这篇格式我自己是从洛谷Markdown复制来的!代码也是我自己写的!并没有抄袭任何人!请Minecraft__Him不要诽谤!!!

【题目网址】

【入门1】顺序结构
B2002 Hello,World!
B2025 输出字符菱形
P1000 超级玛丽游戏
P1001 A+B Problem
B2005 字符三角形
P5703 【深基2.例5】苹果采购
P5704 【深基2.例6】字母转换
P5705 【深基2.例7】数字反转
P5706 【深基2.例8】再分肥宅水
P5708 【深基2.习2】三角形面积
P5707 【深基2.例12】上学迟到
B2029 大象喝水
P1425 小鱼的游泳时间
P1421 小玉买文具
P3954 (NOIP2017 普及组)成绩

B2002 Hello,World!

题目描述

编写一个能够输出 Hello,World! 的程序。
提示:
使用英文标点符号;
Hello,World! 逗号后面没有空格。
H 和 W 为大写字母。

输入格式

输出格式

输入输出样例

输入 #1

输出 #1

Hello,World!

代码如下:

#include<bits/stdc++.h>
using namespace std;//命名空间
int main() {
   
   //表示主函数
	cout<<"Hello,World!"<<endl;//<<endl表示换行
	return 0;//表示结束程序
}

B2025 输出字符菱形

题目描述

用 * 构造一个对角线长 55 个字符,倾斜放置的菱形。

输入格式

没有输入要求。

输出格式

如样例所示。用 * 构成的菱形。

输入输出样例

输入 #1

输出 #1

  *
 ***
*****
 ***
  *

代码如下:

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

P1000 超级玛丽游戏

题目背景

本题是洛谷的试机题目,可以帮助了解洛谷的使用。
建议完成本题目后继续尝试 P1001P1008
另外强烈推荐新用户必读贴

题目描述

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

                ********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###            ###
                ...........               #...#          #...#
               ##*#######                 #.#.#          #.#.#
            ####*******######             #.#.#          #.#.#
           ...#***.****.*###....          #...#          #...#
           ....**********##.....           ###            ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
##########################################    #----------#
#.....#......##.....#......##.....#......#    #----------#
##########################################    #----------#
#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
##########################################    ############

输入格式

输出格式

如描述

AC代码如下:

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

其实这一题中用PHP可以直接输出,代码如下:

                ********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###            ###
                ...........               #...#          #...#
               ##*#######                 #.#.#          #.#.#
            ####*******######             #.#.#          #.#.#
           ...#***.****.*###....          #...#          #...#
           ....**********##.....           ###            ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################----------
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值