求数组中的最大值(C语言)

C语言题目,求一个整型数组中的最大值

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,};
	int max = array[0];
	int size = sizeof(array) / sizeof(array[0]);
	int i = 0;
	for ( i = 0; i < size; i++)
	{
		if (max < array[i])
		{
			max = array[i];
		}
	}
	printf("max of array:%d\n",max);
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/fistraiser/article/details/80207110