- 2
- 0
- 约4.45千字
- 约 5页
- 2020-10-03 发布于安徽
- 举报
#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;
//判重
原创力文档

文档评论(0)