Input 5 numbers in sequence, find the maximum value and output it

#include <stdio.h>
int main()
{
    int i, app, max = 0;//赋第三变量初值
    for (i = 0; i < 5; i++)
    {
        scanf("%d", &app);
        if (i == 0)
            max = app;
        else if (max < app)
            max = app;//若输出后面的值大于前面的值,将最大值存储给max继续与后面的数进行比较
    }
    printf("%d", max);
    return 0;
}

 

Guess you like

Origin blog.csdn.net/m0_62247560/article/details/125037054
Recommended