K-Means的简单模拟

#include
using namespace std;
#define N 1000
int flag[N];
double data[N];
double center[N];
double center_temp[N];
bool result = false;
int n;
double dis(int x,int y)
{
	return (x-y)*(x-y);
}
void print_info()
{
	printf("DATA\n");
	for(int i=0;i 0.001){
				result = true;
				center[i] = center_temp[i];
			}
		}
		print_info();
	}while(result);
}
int main()
{

	cin>>n;
	for(int i=0;i>data[i];
	}
	int k;
	cin>>k;
	k_avg(k);
	print_result(k);
	return 0;
}
/*
10
15 2 3 4 8 79 10 40 5 20
4

10 
0 1 2 3 4 5 6 7 8 9
4

5
40 24 60 80 79
3

5
40 24 20 10 79
3

*/

 

你可能感兴趣的:(K-Means的简单模拟)