依次输入5个数,求其中的最大值并输出

#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;
}

猜你喜欢

转载自blog.csdn.net/m0_62247560/article/details/125037054
今日推荐