C language exercises 01_input and output

C language exercises 01_input and output

Exercise 01 (02) Hello world!

C1-1.在屏幕上显示信息题目描述
要求在屏幕上显示如下信息:
Hello world!
This is a C program.
输入描述
无
输出描述
在屏幕上显示如下信息:(标点符号均为英文的)
Hello world!
This is a C program.
输入样例
无
#include <stdio.h>
int main()
{
    
    
    printf("Hello world!\n");
    printf("This is a C program.\n");
    return 0;
}

Exercise 01 (03) Find the sum of two integers

求两个整数 234 和 567 的和。
输入描述
无
输出描述
无
输入样例
无
输出样例
801
#include <stdio.h>
int main()
{
    
    
    int a, b, sum;
    a = 234;
    b = 567;
    sum = a + b;
    printf("%d\n", sum);
    return 0;
}

Exercise 01 (04) Find the larger of two integers

题目描述
从键盘输入两个整数,求两个整数中的最大者。
输入描述
从键盘输入两个整数,两个整数间以,分隔
输出描述
输出两个整数中的较大者
输入样例
78,45(此处为英文逗号)
输出样例
78
#include <stdio.h>
void main()
{
    
    
    int a, b, c;
    scanf("%d,%d", &a, &b);
    if (a > b)
    {
    
    
        printf("%d", a);
    }
    else
    {
    
    
        printf("%d", b);
    }
}

Exercise 01 (05) Programming to output the largest of the three numbers

题目描述
编写 C 程序,输入三个整数,输出其中最大者。
输入描述
三个数间以,间隔
输出描述
无
输入样例
56,34,100(此处为英文逗号)
输出样例
100
#include <stdio.h>
void main()
{
    
    
    int a, b, c, max;
    scanf("%d,%d,%d", &a, &b, &c);
    if (a > b)
    {
    
    
        max = a;
    }
    else
    {
    
    
        max = b;
    }
    if (max > c)
    {
    
    
        printf("%d", max);
    }
    else
    {
    
    
        printf("%d", c);
    }
}

Exercise 01 (06) Output the corresponding information on the screen

参照书上例程,在屏幕上输出如下信息:
********************(说明:20 个*)
Very good!
********************(20 个*)
输入描述
无
输出描述
无
输入样例
无
输出样例
********************
Very good!
********************
#include <stdio.h>
void main()
{
    
    
	printf("********************\n");
	printf("Very good!\n");
	printf("********************\n");
}

Guess you like

Origin blog.csdn.net/weixin_44179485/article/details/112988649