• 集美大学 - 2840 - 实验1


    -1

    实验1主要是编程入门,了解C语言最基本的代码结构。

    实验1-1 -输入输出格式化控制 Hello World!

    本题要求编写程序,输出一个短句“Hello World!”。

    输入格式:
    本题目没有输入。

    输出格式:
    在一行中输出短句“Hello World!”。

    C语言

    #include
    
    int main() {
        printf("Hello World!");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    说明:C语言的printf()函数是将内容打印到终端上。

    Python

    print("Hello World!")
    
    • 1

    实验1-2-输入输出格式化控制 Welcome to You!

    本题要求编写程序,输出一个短句“Welcome to You!”。

    输入格式:
    本题目没有输入。

    输出格式:
    在一行中输出短句“Welcome to You!”。

    C语言

    #include
    
    int main() {
        printf("Welcome to You!");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    Python

    print("Welcome to You!")
    
    • 1

    实验1-3-输入输出格式化控制 Programming in C is fun!

    本题要求编写程序,输出一个短句“Programming in C is fun!”。

    输入格式:
    本题目没有输入。

    输出格式:
    在一行中输出短句“Programming in C is fun!”。

    C语言

    #include
    
    int main() {
        printf("Programming in C is fun!");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    Python

    print("Programming in C is fun!")
    
    • 1

    实验1-4-输入输出格式化控制 输出三角形

    本题要求编写程序,输出指定的由“*”组成的三角图案。

    输入格式:
    本题无输入

    输出格式:
    按照下列格式输出由“*”组成的三角图案。

    ****
    ***
    **
    *
    
    • 1
    • 2
    • 3
    • 4

    C语言

    #include
    
    int main() {
        printf("****\n***\n**\n*");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    说明:\n是一个转义字符,表示内容换行。

    Python

    print("****")
    print("***")
    print("**")
    print("*")
    
    • 1
    • 2
    • 3
    • 4

    实验1-5-输入输出格式化控制 输出菱形图案

    本题要求编写程序,输出指定的由“A”组成的菱形图案。

    输入格式:
    本题无输入

    输出格式:
    按照下列格式输出由“A”组成的菱形图案。

      A
    A   A
      A
    
    • 1
    • 2
    • 3

    C语言

    #include
    
    int main() {
        printf("  A\nA   A\n  A");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    Python

    print("  A")
    print("A   A")
    print("  A")
    
    • 1
    • 2
    • 3

    实验1-6 -输入输出格式化控制 输出带框文字

    本题要求编写程序,输出指定的带框文字。

    输入格式:
    本题无输入

    输出格式:
    按照下列格式输出带框文字。

    ************
      Welcome
    ************
    
    • 1
    • 2
    • 3

    C语言

    #include
    int main() {
        printf("************\n  Welcome\n************");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5

    Python

    print("************")
    print("  Welcome")
    print("************")
    
    • 1
    • 2
    • 3

    实验1-7-输入输出格式化控制 What is a computer?

    本题要求编写程序,输出一个短句“What is a computer?”。

    输入格式:
    本题目没有输入。

    输出格式:
    在一行中输出短句“What is a computer?”。

    C语言

    #include
    
    int main() {
        printf("What is a computer?");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    Python

    print("What is a computer?")
    
    • 1

    实验1-8-输入输出格式化控制 输出倒三角图案

    本题要求编写程序,输出指定的由“*”组成的倒三角图案。

    输入格式:
    本题目没有输入。

    输出格式:
    按照下列格式输出由“*”组成的倒三角图案。

    * * * *
     * * *
      * *
       *
    
    • 1
    • 2
    • 3
    • 4

    C语言

    #include
    
    int main() {
        printf("* * * *\n * * *\n  * *\n   *");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    Python

    print("* * * *")
    print(" * * *")
    print("  * *")
    print("   *")
    
    • 1
    • 2
    • 3
    • 4
  • 相关阅读:
    图像的表示方法
    v-for的用法及key值原理
    成为数字游民,他们为何「All in Web3」?
    oracle系统负载指标DB_TIME
    Leetcode 1169. 查询无效交易(如果数据量不大,这种题还是得暴力枚举解决)
    物联网网关可以采集水质传感器哪些数据?
    【深入解析spring cloud gateway】07 自定义异常返回报文
    Electron+Vue开源软件:洛雪音乐助手V2.8畅享海量免费歌曲
    入门简单,轻量好用的低代码开发平台推荐
    docker-compose的安装与卸载
  • 原文地址:https://blog.csdn.net/im34v/article/details/126540201