求助,C语言中怎么进行地址间的排列组合?
先贴代码
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "emd.h"
float dist(feature_t *F1, feature_t *F2)
{
int dX = F1->X - F2->X, dY = F1->Y - F2->Y;
return sqrt(dX*dX + dY*dY );
}
void main()
{
feature_t
f1[31] = { { 31,1 },{ 5,12 },{ 5,13 },{ 6,13 },{ 7,14 },{ 8,13 },{ 9,14 },{ 10,12 },{ 10,13 },{ 10,15 },{ 11,10 },{ 11,16 },{ 12,8 },{ 12,9 },{ 12,16 },{ 14,9 },{ 15,9 },{ 16,11 },{ 16,14 },{ 16,15 },{ 16,16 },{ 19,17 },{ 21,16 },{ 22,16 },{ 25,16 },{ 26,15 },{ 28,15 },{ 33,13 },{ 5,12 },{ 32,2 },{ 26,4 } },
f2[16] = { { 5,13 },{ 7,14 },{ 9,15 },{ 11,16 },{ 12,9 },{ 12,17 },{ 14,11 },{ 15,16 },{ 16,12 },{ 16,13 },{ 17,14 },{ 18,15 },{ 18,16 },{ 20,9 },{ 7,9 },{ 28,6 } },
f3[2] = { {1,2},{3,4} };
float
w1[31] = { 0.114,0.045,0.023,0.023,0.023,0.023,0.068,0.023,0.045,0.023,0.023,0.023,0.045,0.045,0.045,0.023,0.023,0.023,0.023,0.023,0.045,0.023,0.023,0.045,0.023,0.023,0.023,0.023,0.023,0.023,0.023 },
w2[16] = { 0.053,0.053,0.053,0.053,0.053,0.053,0.053,0.053,0.053,0.053,0.158,0.105,0.053,0.053,0.053,0.053 },
w3[2] = { 0.5,0.5 };
signature_t
s1 = { 31, f1, w1 },
s2 = { 16, f2, w2 },
s3 = { 2, f3, w3 };
float e;
e = emd(&s1, &s2, dist, 0, 0);
printf("emd=%f\n", e);
system("pause");
}
上文中我一共要输入n个地址: s1,s2,s3···sn (这里我只输入了3个,实际需求大概要输入100个左右). 但最后的计算函数emd是对两个地址进行代入计算,想问有没有什么办法可以将这n个地址进行两两组合,并代入到emd函数中进行运算。