算法导论 思考题 15-8(基于接缝裁剪的图像压缩)

#include 
#include 
#include 
#define M 8
#define N 10

int A[M][N]=
{
	{1,2,3,4,5,6,7,8,9,10},
	{2,3,4,5,6,7,8,9,10,11},
	{8,4,6,2,7,2,7,8,12,15},
	{10,23,5,7,9,10,13,9,18,20},
	{4,8,1,9,23,6,8,11,17,30},
	{9,5,1,7,5,7,5,19,6,8},
	{10,45,7,2,8,2,6,8,2,13},
	{10,5,30,29,5,8,6,2,5,20},
};

int B[M][N]={0};
int C[M][N]={0};

int minOf3(int a,int b,int c)
{
	if(a<=b && a<=c)
		return a;
	else if(b<=c)
		return b;
	else
		return c;
}

int getMin(int i,int j)
{
	int a1,a2,a3;
	if(j-1>=0)
		a1=B[i-1][j-1];
	else
		a1=INT_MAX;
	a2=B[i-1][j];
	if(j+1=0;i--)
	{
		printf("col%d:%d ",j+1,A[i][j]);
		j+=C[M-1][j];
	}
	printf("\n");
}

int getResult()
{
	int min=INT_MAX,mini;
	for(int i=0;i

你可能感兴趣的:(算法导论)