#include <stdio.h>

#define SZ_Y (10)
#define SZ_X (10)
#define SZ_YX ( SZ_Y * SZ_X )

int main( void )
{
	int count = 0, height = SZ_Y, width = SZ_X;
	double x_g = 0.0, y_g = 0.0;
	unsigned char img_src[ SZ_YX ] = { 0 };
	char img_tmp[ SZ_YX + 1 ] =
	//...0123456789
		".........." // 0
		".........." // 1
		".........." // 2
		"...ooooo.." // 3
		"...ooooo.." // 4
		"...ooxoo.." // 5
		"...ooooo.." // 6
		"...ooooo.." // 7
		".........." // 8
		"..........";// 9

	for( int i = 0; i < SZ_YX; i++ )
	{
		if( '.' != img_tmp[ i ] )
		{
			img_src[ i ] = 255;
		}
	}

	for( int y = 0; y < height; y++ )
	{
		for( int x = 0; x < width; x++ )
		{
			if( 255 == img_src[ y * width + x ] )
			{
				count++;
				x_g += x;
				y_g += y;
			}
		}
	}
	x_g /= count;
	y_g /= count;

	printf( "重心(x, y) = (%f, %f)\n", x_g, y_g );
	return 0;
}


