#include <file.h>
#include <sys/types.h>
#include <fcntl.h>
#include<stdio.h>
int main(int argc, char **argv)
{
  FILE *fp;
  int del;
  int *pdel = &del ;
  int i=0, j;
  int thresh, classes, bins;
  int *cl;
  int maxcl=0;
  if(argc < 3)
  {
  	printf("%s <thresh> <bins>\n", argv[0]);
	return (-1);
  }
  thresh = atoi(argv[1]);
  bins = atoi(argv[2]);
  classes = thresh/bins;
  cl = (int *)calloc(bins, sizeof(int));
  memset(cl, 0, classes*sizeof(int));
  
  if((fp = fopen("./dels", "r")) == NULL)
  	perror("fopen");
  while (!feof(fp))
  {
  	if(fread((char *)pdel, sizeof(int), 1, fp )< 0)
	{
		perror("fread");
		return(-1);
	}
	if(i>3)
	  if(del > thresh)
	  	printf("%d %d\n",i, del);
	for (j=0; j<bins; j++)
	{
		if((del > classes*j) &&(del < classes*(j+1)))
			cl[j]++;
	  (cl[j] > maxcl)? (maxcl = cl[j]): (maxcl); 
	} 	
	i++;
  }
  for (j=0; j<bins; j++)
  {
 
/*	printf("%d\t|", j*classes);
	for(i=0 ; i< cl[j] *65/maxcl; i++)
		printf("#");
	printf("\n");	
*/	
	printf("cl[%d] = %d\n", j, cl[j]);	
  }
fclose(fp);
}