Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6. FILE *fp;
  7. char line[80],*pch;
  8. int points[1000][10];
  9. int centroid[1000][10];
  10. float distance[1000][10];
  11. int noofpts=0,noofvar=0,noofcentroids=0;
  12. int i=0,j=0,k;
  13.  
  14. fp=fopen("kmeans.dat","r");
  15. while(fgets(line,80,fp)!=NULL)
  16. {
  17. j=0;
  18. pch=strtok(line,",");
  19. while(pch!=NULL)
  20. {
  21. points[i][j]=(int)pch;
  22. pch=strtok(NULL,",");
  23. noofvar++;
  24. j++;
  25. }
  26. noofpts++;
  27. i++;
  28. }
  29. noofvar=noofvar/noofpts;
  30. printf("No of points-%dn",noofpts);
  31. printf("No of variables-%dn",noofvar);
  32.  
  33. return 0;
  34. }
  35.  
  36. points[i][j]=(int)pch;
  37.  
  38. points[i][j]=atoi(pch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement