K-mea-ns C语言代码.docVIP

  • 4
  • 0
  • 约4.17千字
  • 约 5页
  • 2017-01-20 发布于湖北
  • 举报
#include stdio.h #include math.h #include time.h #include stdlib.h #define TRUE 1 #define FALSE 0 int N;//数据个数 int K;//集合个数 int * CenterIndex;//初始化质心数组的索引 double * Center;//质心集合 double * CenterCopy;//质心集合副本 double * AllData;//数据集合 double ** Cluster;//簇的集合 int * Top;//集合中元素的个数,也会用作栈处理 //随机生成k个数x(0=x=n-1)作为起始的质心集合 void CreateRandomArray(int n, int k,int * center) { int i=0; int j=0; srand((unsigned)time(NULL)); for( i=0;ik;++i)//随机生成k个数 { int a=rand()%n; //判重 for(j=0;ji;j++) { if(center[j]==a)//重复

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档