求10个整数中的最大值

求10个整数中的最大值
#include <stdio.h>
#include <windows.h>
int main()
{
int a[] = { 12, 15, 45, 78, 21, 36, 42, 69, 96, 86 }; //定义一个数组a
int size = sizeof(a) / sizeof(a[10]); //获取数组中元素的个数
int max = a[0]; //数组中元素从0开始
int i = 1;
for (i; i < size;i+=1) //如果i小于size,i加1
if (max < a[i]) //如果这个值小于数组i,则这个数就是最大值
{
max = a[i];
}
printf("%d\n", max); //打印这个最大值
system(“pause”);
return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43224539/article/details/82832647