• 【NOI OpenJudge】【1.1】编程基础之输入输出


    在这里插入图片描述

    01:Hello, World!

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main(){
        printf("Hello, World!");
        return 0;
    }
    

    02:输出第二个整数

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main(){
        int a,b,c;
        cin>>a>>b>>c;
        printf("%8d %8d %8d",a,b,c);
        return 0;
    }
    

    03:对齐输出

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main(){
        int a,b,c;
        cin>>a>>b>>c;
        printf("%8d %8d %8d",a,b,c);
        return 0;
    }
    

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

    #include<cstdio>
    int main(){
        double x;
        scanf("%lf",&x);
        printf("%.3lf
    ",x);
        return 0;
    }
    

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

    #include<cstdio>
    int main(){
        double x;
        scanf("%lf",&x);
        printf("%.12lf
    ",x);
        return 0;
    }
    

    06:空格分隔输出

    #include<cstdio>
    int main(){
        char a;
        int b;
        float c;
        double d;
        scanf("%c%d%f%lf",&a,&b,&c,&d);
        printf("%c %d %f %lf", a, b, c, d);
        return 0;
    }
    

    07:输出浮点数

    #include<cstdio>
    int main(){
        double x;
        scanf("%lf",&x);
        printf("%lf
    %.5lf
    %e
    %g
    ",x,x,x,x);
        return 0;
    }
    

    08:字符三角形

    #include<cstdio>
    int main(){
        int n = 3;
        char ch;
        ch = getchar();
        for(int i = 1; i <= n; i++){
            int e = i*2-1;
            int blank = (5-e)/2;
            for(int j = 1; j <= blank; j++){
                printf(" ");
            }
            for(int j = 1; j <= e; j++){
                printf("%c",ch);
            }
            printf("
    ");
        }
        return 0;
    }
    

    09:字符菱形

    #include<cstdio>
    int main(){
        int n = 3;
        char ch;
        ch = getchar();
        for(int i = 1; i <= n; i++){
            int e = i*2-1;
            int blank = (5-e)/2;
            for(int j = 1; j <= blank; j++){
                printf(" ");
            }
            for(int j = 1; j <= e; j++){
                printf("%c",ch);
            }
            printf("
    ");
        }
        for(int i = n-1; i >= 1; i--){
            int e = i*2-1;
            int blank = (5-e)/2;
            for(int j = 1; j <= blank; j++){
                printf(" ");
            }
            for(int j = 1; j <= e; j++){
                printf("%c",ch);
            }
            printf("
    ");
        }
        return 0;
    }
    

    10: 超级玛丽游戏

    #include<cstdio>
    int main(){
        printf("                ********
    ");
        printf("               ************
    ");
        printf("               ####....#.
    ");
        printf("             #..###.....##....
    ");
        printf("             ###.......######              ###                 ###           ###           ###
    ");
        printf("                ...........               #...#               #...#         #...#         #...#
    ");
        printf("               ##*#######                 #.#.#               #.#.#         #.#.#         #.#.#
    ");
        printf("            ####*******######             #.#.#               #.#.#         #.#.#         #.#.#
    ");
        printf("           ...#***.****.*###....          #...#               #...#         #...#         #...#
    ");
        printf("           ....**********##.....           ###                 ###           ###           ###
    ");
        printf("           ....****    *****....
    ");
        printf("             ####        ####
    ");
        printf("           ######        ######
    ");
        printf("##############################################################              ##################################
    ");
        printf("#...#......#.##...#......#.##...#......#.##------------------#              #...#......#.##------------------#
    ");
        printf("###########################################------------------#              ###############------------------#
    ");
        printf("#..#....#....##..#....#....##..#....#....#####################              #..#....#....#####################
    ");
        printf("##########################################    #----------#                  ##############    #----------#
    ");
        printf("#.....#......##.....#......##.....#......#    #----------#                  #.....#......#    #----------#
    ");
        printf("##########################################    #----------#                  ##############    #----------#
    ");
        printf("#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#                  #.#..#....#..#    #----------#
    ");
        printf("##########################################    ############                  ##############    ############
    ");
    }
    
  • 相关阅读:
    BZOJ_2002_[Hnoi2010]Bounce 弹飞绵羊_LCT
    BZOJ_4154_[Ipsc2015]Generating Synergy_KDTree
    BZOJ_2801_[Poi2012]Minimalist Security_dfs树+特判+乱搞
    BZOJ_3123_[Sdoi2013]森林_主席树+启发式合并
    2019集训队作业做题实况[1](1-30):
    牛客挑战赛33 F 淳平的形态形成场(无向图计数,EGF,多项式求逆)
    【NOIP2019模拟2019.10.07】果实摘取 (约瑟夫环、Mobius反演、类欧、Stern-Brocot Tree)
    CodeChef Max-digit Tree(动态规划)
    骚操作:c++如何用goto便捷地写人工栈?
    Comet OJ
  • 原文地址:https://www.cnblogs.com/gwj1314/p/10200062.html
Copyright © 2020-2023  润新知