averagevalue.c

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

C
31
字号
/*
 *  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 
 *  average value of a integer array. Note this code stresses
 *  simplicity over robustness and efficiency.
*/

int averageValue( int [], int);

// Requires:	array_size equals the number of elements in the array, array_size > 0
// Returns:		The average value of the integer array  
int averageValue( int values[], int array_size)
{	
	int total = 0;
	int i = 0;
			
	for (i = 0; i < array_size; i++) {
		total = total + values[i];
	}

	return (int)total/array_size; 
}
	

⌨️ 快捷键说明

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