#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<fstream.h>

int main()
{
  int i, j, k, l, m, n, o, p, N;
  char fname[80], line[80];
  FILE *mfile;
  
  N = 0;
  srand(8);
  
  sprintf(fname, "missa8_16.txt");
  if ((mfile = fopen(fname, "w")) == NULL)
    printf ("Unable to open file %s\n", fname);
  else
    for (i = 0; i < 16; i++)
      for (j = i+1; j < 16; j++)
        for (k = j+1; k < 16; k++)
          for (l = k+1; l < 16; l++)
          for (m = l+1; m < 16; m++)
          for (n = m+1; n < 16; n++)
          for (o = n+1; o < 16; o++)
          for (p = o+1; p < 16; p++)
          {
            if (N == 2000)
              break;
            else 
            if (rand() > 0.8455*RAND_MAX)
            {
              sprintf (line, "%d %d %d %d %d %d %d %d 10000", i, j, k, l, m, n, o, p);
              fprintf(mfile, "%s\n", line);
              N++;
            }
          }
  fclose(mfile);
  
  printf("N = %d\n", N);
  //printf("RAND_MAX = %d\n", RAND_MAX);
  return 0; 
}