t time; loaddata(); getmaxmin(data); while(1) { K_locations_random(); end_flag=cluster(); if(existemptyclass()) {printf("There isa empty class!\nSo restart!\n");continue;} time=0; while(!end_flag) { if(time>1000)break; time++; update_k_location(); end_flag=cluster(); } empty_flag=existemptyclass(); if(empty_flag) {printf("There isa empty class!\nSo restart!\n");continue;} else break; } printf("\nAfter %ld times calculation\n",time); output(); freememory(); } 实验数据文件: data.txt 用空格分开 K=3,Vectordim=3,datasize=15 -25 22.2 -35.34 31.2 -14.4 23 32.02 -23 24.44 -25.35 36.3 -33.34 -20.2 27.333 -28.22 -15.66 17.33 -23.33 26.3 -31.34 16.3 -22.544 16.2 -32.22 12.2 -15.22 22.11 -41.241 25.232 -35.338 -22.22 45.22 23.55 -34.22 50.14 30.98 15.23 -30.11 20.987 -32.5 15.3 -25.22 -38.97 20.11 33.22 五、结果截图 7