洛谷【入门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!

C++

#include <iostream>

using namespace std;

int main(int argc, char** argv) {
	cout<<"Hello,World!"<<endl;
	return 0;
}

C

#include<stdio.h>
int main(){
    printf("Hello,World!");
    return 0;
}

Pascal

begin
write('Hello,World!')
end.

Python 3

print("Hello,World!")

java8

public class Main{
    public static void main(String[] args) {
        System.out.println("Hello,World!");
    }
}

PHP

Hello,World!

B2025 输出字符菱形

PHP

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

C++

#include<iostream>

using namespace std;

int main()

{

    cout<<"  * "<<endl;

    cout<<" *** "<<endl;

    cout<<"*****"<<endl;

    cout<<" *** "<<endl;

    cout<<"  * "<<endl;

    return 0;

}

P1000 超级玛丽游戏

C++

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

P1001 A+B Problem

#include <iostream>
#include <cstdio>
 
using namespace std;
 
int main() {
    int a,b;
    cin >> a >> b;
    cout << a + b;
    return 0;
}

B2005 字符三角形

#include<iostream>
using namespace std;
int main()
{
	char n;
	scanf("%c",&n);
	printf("  %c\n",n);
	printf(" %c%c%c\n",n,n,n);
	printf("%c%c%c%c%c",n,n,n,n,n);
	return 0;
}

P5703 【深基2.例5】苹果采购

#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

P5704 【深基2.例6】字母转换

#include<bits/stdc++.h>
using namespace std;
int main(){
    putchar(getchar()-'a'+'A');
    return 0;
}

P5705 【深基2.例7】数字反转

#include <cstdio>

using namespace std;
char a, b, c, d;
int main(){
	scanf("%c%c%c.%c", &a, &b, &c, &d);
	printf("%c.%c%c%c", d, c, b, a);
	return 0;
}

P5706 【深基2.例8】再分肥宅水

#include<bits/stdc++.h>
using namespace std;

int main(){
	double a;
	int b;
	cin>>a>>b;
	cout<<setprecision(3)<<fixed<<a/b<<endl<<b*2;
	return 0;
}

P5708 【深基2.习2】三角形面积

#include<bits/stdc++.h>
using namespace std;
double a,b,c,p,ans;
int main()
{
	cin>>a>>b>>c;
	p=(a+b+c)/2;
	ans=sqrt(p*(p-a)*(p-b)*(p-c));
	printf("%.1lf",ans);
	return 0;
}

P5707 【深基2.例12】上学迟到

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double a,v;
	double i,n;
	double c,g;
	cin>>a>>v;
	c=ceil(a/v);
	c=c+10;
	i=floor(c/60);
	n=c-i*60.0;
	if(n!=0)
	{
		n=60-n;
		i=8-1-i;
		if(i<0)
		{
			i=24-abs(i);
		}
	}
	if(n==0)
	{
		i=8-i;
		if(i<0)
		{
			i=24-abs(i);
		}
	}
	if(i>=10&&n>=10)
	{
		cout<<i<<":"<<n<<endl;
	}
	if(i>=10&&n<10)
	{
		cout<<i<<":"<<"0"<<n<<endl;
	}
	if(i<10&&n>=10)
	{
		cout<<"0"<<i<<":"<<n<<endl;
	}
	if(i<10&&n<10)
	{
		cout<<"0"<<i<<":"<<"0"<<n<<endl;
	}
	return 0;
}

B2029 大象喝水

#include <iostream>
using namespace std;
int main()
{
	int h,r;
	float tj,Pi=3.14159;
	cin>>h>>r;
	tj=Pi*r*r*h;
	cout<<int(20000/tj)+1;
return 0;
}

P1425 小鱼的游泳时间

#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=c-a,y=d-b;
    if(y<0){x--;y+=60;}
    cout<<x<<" "<<y;
    return 0;
}

P1421 小玉买文具

#include<cstdio>
int main()
{
    int a,b;//a元b角
    int c;//转换后的班主任给的价钱
    scanf("%d %d",&a,&b);
    c=a*10+b;//把a元b角转换为a*10+b角
    printf("%d",c/19);//19在这里表示19角,原来是1.9元,不过已经被转换掉了
    return 0;
}

P3954 [NOIP2017 普及组] 成绩

#include<iostream>
using namespace std;
int main()
{
	int a,b,c;//定义3种成绩 
	cin>>a>>b>>c;//输入
	cout<<a*0.2+b*0.3+c*0.5;//输出 
	return 0; 
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值