maximumvalue.c

来自「基于DSP2000的例程」· C语言 代码 · 共 34 行

C
34
字号
/*
 *  Copyright (c) 2001-2002, Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
*/

/*
 * Description: Library function to determine the 
 * maximum value within a integer array. Note this code stresses
 * simplicity over robustness and efficiency.
*/

int maximumValue( int [], int);

// Requires:	array_size equals the number of elements in the array, array_size > 0
// Returns:		The maximum value contained in the integer array  
int maximumValue( int values[], int array_size)
{	
	int maximum_value;
	int i = 0;
			
	maximum_value = values[0];

	for (i = 0; i < array_size; i++) {
		if (values[i] > maximum_value) 
			maximum_value = values[i];
	}
	
	return maximum_value;
}
	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?