#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int x[5] = { 4,8,7,3,9 };
int max = x[0];
int lim = x[0];
int i, n, m, w = 0;
for (i = 0; i < 5; i++)
{
if (max < x[i])//if语句下面接的大于等于2条雨具时要记得加大括号
{
max = x[i];//将max与x[i]中的每一个做对比,满足if就会将max替换
n = i;
}
}
for (w = 0; w < 5; w++)
{
if (lim > x[w])
{
lim = x[w];
m = w;
}
}
printf("最大值为%d,下标为%d,最小值为%d,下标为%d",max,n,lim,m);
return 0;
}