OpenJudge NOI题库1.1答案

文章列举了C++中的多个基础编程示例,包括输出文本、整数、浮点数的格式化,以及字符图形如三角形、菱形和超级玛丽游戏的绘制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这些代码都是通过测试的

1.Hello, World!

#include<bits/stdc++.h>
using namespace std;
int main(){
    cout<<"Hello, World!";
    return 0;
}

02.输出第二个整数

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<b;
    return 0;
}

03.对齐输入

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    printf("%8d %8d %8d\n",a,b,c);
    return 0;
}


04.输出保留3位小数的浮点数

#include<bits/stdc++.h>
using namespace std;
int main(){
    float a;
    cin>>a;
    cout<<fixed<<setprecision(3)<<a;
    return 0;
}


05.输出保留12位小数的浮点数

#include<bits/stdc++.h>
using namespace std;
int main(){
    double a;
    cin>>a;
    cout<<fixed<<setprecision(12)<<a;
    return 0;
}


06.空格分隔输出

#include<bits/stdc++.h>
using namespace std;
int main(){
    char a;
    long long b;
    float c;
    double d;
    cin>>a>>b>>c>>d;
    cout<<a<<' '<<b<<' '<<fixed<<setprecision(6)<<c<<' '<<fixed<<setprecision(6)<<d;
    return 0;
}


07.输出浮点数

#include<bits/stdc++.h>
using namespace std;
int main(){
    double d;
    cin>>d;
    printf("%f\n%.5lf\n%e\n%g\n",d,d,d,d);
    return 0;
}


08.字符三角形

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

09.字符菱形

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


10.超级玛丽游戏

#include<bits/stdc++.h>
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<<"##########################################    #----------#                  ##############    #----------#"<<endl<<"#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#                  #.#..#....#..#    #----------#"<<endl<<"##########################################    ############                  ##############    ############"<<endl; 
    return 0;
}


 



 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值