예제 #1
0
int main(void)
{
	int total, n;
	long long int rank;
	int i;
////	freopen("kimbits.in", "r", stdin);
////	freopen("kimbits.out", "w", stdout);

	make_tab();
	while(scanf("%d%d%lld", &total, &n, &rank) != EOF){
		for(i=total; i>0; i--){
			if(n > i-1)
				n = i-1;
			if(rank > num[i-1][n]){
				printf("1");
				rank -= num[i-1][n];
				n--;
			}
			else
				printf("0");
		}
		printf("\n");
	}
	return 0;
}
예제 #2
0
파일: main.c 프로젝트: 1lynx/Project_perso
int main(int ac, char **str)
{
  struct s_list *stru;
  char move;
  int x;
  int y;
  x = 0;
  y = 0;
  int grille[10][10] =
{
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},

};
    while (grille[9][9] == 0)
    {
      make_tab(grille);
      move = getch();
      mover(move, grille, &x, &y);
      system("clear");
    }

  return(0);
}
예제 #3
0
파일: main.c 프로젝트: barug/Epitech
int		main(int argc, char **argv, char **envp)
{
  t_tabnfo	*tabnfo;
  t_maxsquare	*maxsquare;

  argc = argc;
  if (load_termcaps(envp) == -1)
    return (-1);
  if ((tabnfo = malloc(sizeof(t_tabnfo))) == NULL)
    return (-1);
  if ((maxsquare = malloc(sizeof(t_maxsquare))) == NULL)
    return (-1);
  if (make_tab(argv[1], tabnfo) == -1)
    return (-1);
  if (check_tab(tabnfo) == -1)
    return (-1);
  if (find_maxsquare(tabnfo, maxsquare) == -1)
    {
      my_printf("no possible square");
      return (-1);
    }
  my_printf("FOUND:\n");
  make_maxsquare(tabnfo, maxsquare);
  display_tab(tabnfo);
  free_tabnfo(tabnfo);
  return (0);
}
예제 #4
0
WORD do_all( BYTE *filename )
{
	/* Hauptroutine */
	BYTE	*temp_file_name;

	/* Info-Datei lesen */
	if( read_info_file() < 0 )
		/* Fehler */
		return( -1 );

	/* Zeile zuruecksetzen */
	zeile = 1;

	/* Grammatik-Datei lesen */
	if( read_grammar_file( filename ) < 0 )
		/* Fehler */
		return( -1 );

	/* Die Hash-Tabelle initialisieren */
	if( ( hash_tab = ( HASH_TAB * ) calloc( lr_info.hash_tab_size, sizeof( HASH_TAB ) ) ) == NULL )
		/* Fehler */
		return( error( NOT_ENOUGH_MEMORY, 0, 0 ) );

	/* Dateinamen ausgeben */
	if( output_file_msg( filename ) < 0 )
		/* Fehler */
		return( -1 );

	/* Ausgaben in Datei bzw. auf den Bildschirm */
	if( lr_info.dest == DFILE )
	{
		/* Dateinamen aufbereiten */
		temp_file_name = strrchr( filename, ( WORD ) '.' );
		strcpy( temp_file_name, ".TXT" );

		/* Datei zum Schreiben �ffnen */
		file = freopen( filename, "w", 0L );
	}

	/* Ausgabe auf Bildschirm ? */
	else if( lr_info.dest == DSCREEN )
		/* Bildschirm */
		file = stdout;

	else
		/* Drucker */
		file = stdprn;

	/* Ausgabe der Fehler auf Bildschirm ? */
	if( lr_info.err_dest == DSCREEN )
		/* Bildschirm */
		err_file = stderr;

	else
		/* Drucker */
		err_file = stdprn;

	/* Grammatik analysieren */
	if( analyze_grammar() < 0 )
		/* Fehler */
		return( -1 );

	/* Speicher der Grammatik-Datei freigeben */
	free_mem( ( VOID * ) &grammar );

	/* Grammatik in BNF ausgeben ? */
	if( !lr_info.output_grammar )
	{
		/* Ja */
		if( output_grammar() < 0 )
			/* Fehler */
			return( -1 );
	}

	/* Items generieren */
	if( generate_items() < 0 )
		/* Fehler */
		return( -1 );

	/* Die LR-Tabelle erzeugen */
	if( make_tab() < 0 )
		/* Fehler */
		return( -1 );

	/* FIRST-Mengen ausgeben ? */
	if( !lr_info.first )
	{
		/* Ja */
		if( output_first() < 0 )
			/* Fehler */
			return( -1 );
	}

	/* FOLLOW-Mengen ausgeben ? */
	if( !lr_info.follow )
	{
		/* Ja */
		if( output_follow() < 0 )
			/* Fehler */
			return( -1 );
	}

	/* Items ausgeben ? */
	if( !lr_info.lr_items )
	{
		/* Ja */
		if( output_items() < 0 )
			/* Fehler */
			return( -1 );
	}

	/* LR-Tabelle ausgeben ? */
	if( !lr_info.lr_tab )
	{
		/* Ja */
		if( output_lr_tab() < 0 )
			/* Fehler */
			return( -1 );
	}

	/* LR-Tabelle optional komprimieren */
	if( !lr_info.compress )
	{
		/* LR-Tabelle komprimieren */
		if( compress_lr_tab() < 0 )
			/* Fehler */
			return( -1 );
	}

	/* Parser-Quelltext erzeugen */
	if( generate_parser() < 0 )
		/* Fehler */
		return( -1 );

	/* Alles OK */
	return( 0 );
}
예제 #5
0
파일: stream.c 프로젝트: BioDAG/align-paths
mclx* mclxIOstreamIn
(  mcxIO*   xf
,  mcxbits  bits
,  mclpAR*  transform
,  void    (*ivpmerge)(void* ivp1, const void* ivp2)
,  mclxIOstreamer* streamer
,  mcxOnFail ON_FAIL
)
   {  mcxstatus status  =  STATUS_FAIL
   ;  const char* me    =  module

   ;  mcxbool symmetric =  bits & MCLXIO_STREAM_SYMMETRIC
   ;  mcxbool mirror    =  bits & MCLXIO_STREAM_MIRROR

   ;  mcxbool abc       =  bits & MCLXIO_STREAM_ABC    ? TRUE : FALSE
   ;  mcxbool one23     =  bits & MCLXIO_STREAM_123    ? TRUE : FALSE
   ;  mcxbool etc       =  bits & (MCLXIO_STREAM_ETC | MCLXIO_STREAM_ETC_AI) ? TRUE : FALSE

   ;  mcxbool longlist  =  bits & (MCLXIO_STREAM_ETCANY | MCLXIO_STREAM_235ANY) ? TRUE : FALSE

   ;  mcxTing* linebuf  =  mcxTingEmpty(NULL, 100)

   ;  map_state  map_c  =  { NULL, NULL, -1 , 0}
   ;  map_state  map_r  =  { NULL, NULL, -1 , 0}

   ;  stream_state   iface
   ;  etc_state      etcstate

   ;  unsigned long n_ite = 0
   ;  mclx* mx = NULL

   ;  if (!ivpmerge)
      ivpmerge = mclpMergeMax

   ;  if (symmetric)
         iface.map_c = &map_c    /* this bit of hidgery-pokery       */
      ,  iface.map_r = &map_c    /* is a crucial interfacummathingy  */
   ;  else
         iface.map_c = &map_c
      ,  iface.map_r = &map_r

;if(DEBUG2)fprintf(stderr, "%s abc\n", abc ? "yes" : "no")
   ;  etcstate.etcbuf = NULL
   ;  etcstate.etcbuf_ofs = 0
   ;  etcstate.etcbuf_check = 0
   ;  etcstate.x_prev   =  ULONG_MAX      /* note we depend on ULONG_MAX + 1 == 0 */
   ;  etcstate.n_y   =  0

         /* fixme incomplete and distributed initialization of iface */
   ;  iface.pars = NULL
   ;  iface.pars_n_alloc = 0
   ;  iface.pars_n_used = 0

;if(DEBUG3)fprintf(stderr, "1 + max c %lu\n", (ulong) (iface.map_c->max_seen+1))
                                 /* fixme: put the block below in a subroutine */
   ;  while (1)
      {  if (abc + one23 + longlist > TRUE)   /* OUCH */
         {  mcxErr(module, "multiple stream formats specified")
         ;  break
      ;  }
         if (!symmetric && streamer->tab_sym_in)
         {  mcxErr(module, "for now disallowed, single tab, different domains")
         ;  break
      ;  }
         if ((!one23 && !abc && !longlist))
         {  mcxErr(module, "not enough to get going")
         ;  break
      ;  }

                              /* These have maps associated with them.
                               * Note that bitsp may be changed (by filling in
                               * somewhat underspecified settings).
                               * todo hierverder: etc case supported below ?
                              */
         if (abc || etc)
         stream_state_set_map(symmetric, &iface, streamer, &bits)

      ;  if (xf->fp == NULL && (mcxIOopen(xf, ON_FAIL) != STATUS_OK))
         {  mcxErr(me, "cannot open stream <%s>", xf->fn->str)
         ;  break
      ;  }
         status = STATUS_OK
      ;  break
   ;  }

      iface.bits  =  bits

   ;  if (!status)
      while (1)
      {  unsigned long x = 876543210, y = 876543210
      ;  double value = 0
      ;  n_ite++

      ;  iface.x =  0
      ;  iface.y =  0

      ;  if (n_ite % 20000 == 0)
         fputc('.', stderr)               /* fixme conditional to sth */
      ;  if (n_ite % 1000000 == 0)
         fprintf(stderr, " %ldM\n", (long) (n_ite / 1000000))

                        /* 
                         * -  the read routines largely manage iface, including
                         * map_c->max_seen and map_r->max_seen.  It would be
                         * nice to encapsulate that management in a single
                         * place. Note the read_abc requirement that sometimes
                         * a label may need to be deleted from a hash. The fact
                         * that handle_label (called by read_etc and read_abc)
                         * also manages max_seen complicate encapsulation though.
                         *
                         * -  read_etc manages its line buffer.
                        */
      ;  status
         =     one23 ?     read_123(xf, linebuf, &iface, streamer, &value, bits)
            :  abc   ?     read_abc(xf, linebuf, &iface, &value)
            :  longlist ?  read_etc(xf, &iface, &etcstate, &value)
            :  STATUS_FAIL

      ;  x = iface.x
      ;  y = iface.y

                        /* considerme: etc status ignore could still expand column range.
                         * do we change the status and deal with not incorporating the row,
                         * or do we keep status, and change realloc/ignore logic below?
                        */
;if(0)fprintf(stderr, "#x now %lu status %s\n", (ulong) (iface.map_c->max_seen+1), MCXSTATUS(status))
                        /* etc/235 are special in that with NEW x and IGNORE y
                         * we respect x
                         * fixme: should not do that for auto-increment
                        */
      ;  if (status == STATUS_IGNORE)     /* maybe restrict mode */
         {  if
            (  longlist
            && iface.statusx == STATUS_NEW
            && iface.map_c->max_seen+1 > iface.pars_n_used    /* note mixed-sign comparison */
            )
            {  if ((status = pars_realloc(&iface, iface.map_c->max_seen+1)))
               break
         ;  }
            continue
      ;  }
         else if (status)                 /* FAIL or DONE */
         break

      ;  if
         (  iface.map_c->max_seen >= iface.pars_n_used     /* note mixed-sign comparison */
         && (status = pars_realloc(&iface, iface.map_c->max_seen+1))
         )
         break

      ;  status = STATUS_FAIL    /* fixme restructure logic, mid-re-initialization is ugly */

      ;  if
         ( bits & (MCLXIO_STREAM_LOGTRANSFORM | MCLXIO_STREAM_NEGLOGTRANSFORM) )
         {  if (bits & MCLXIO_STREAM_LOGTRANSFORM)
            value = value > 0 ? log(value) : -PVAL_MAX
         ;  else if (bits & MCLXIO_STREAM_NEGLOGTRANSFORM)
            value = value > 0 ? -log(value) : PVAL_MAX
         ;  if (bits & MCLXIO_STREAM_LOG10)
            value /= log(10)
      ;  }

         if (transform)
         {  mclp bufivp
         ;  bufivp.idx = 0
         ;  bufivp.val = value
         ;  value = mclpUnary(&bufivp, transform)
      ;  }

                                 /* fixme: below we have canonical dependence, index as offset */
         if (value)
         {  if(DEBUG3)fprintf(stderr, "attempt to extend %d\n", (int) x)
         ;  if (mclpARextend(iface.pars+x, y, value))
            {  mcxErr(me, "x-extend fails")
            ;  break
         ;  }
            if (mirror && mclpARextend(iface.pars+y, x, value))
            {  mcxErr(me, "y-extend fails")
            ;  break
         ;  }
         }
         status = STATUS_OK
   ;  }

      if (n_ite >= 1000000 && n_ite % 5000000)
      fputc('\n', stderr)

   ;  mcxTingFree(&(etcstate.etcbuf))

   ;  if (status == STATUS_FAIL || ferror(xf->fp))
      mcxErr(me, "error occurred (status %d lc %d)", (int) status, (int) xf->lc)
   ;  else
      {  mx = make_mx_from_pars(streamer, &iface, ivpmerge, bits)
      ;  status = mx ? STATUS_OK : STATUS_FAIL
   ;  }

      mcxTingFree(&linebuf)
   ;  free_pars(&iface)

   ;  if (status == STATUS_FAIL)
      {  if (ON_FAIL == EXIT_ON_FAIL)
         mcxDie(1, me, "fini")
   ;  }

               /* with 123, etcai there is simply no column tab
                * todo: perhaps create a dummy one (integers).
               */
      if
      (  !status
      && (abc || (bits & (MCLXIO_STREAM_ETC | MCLXIO_STREAM_ETC_AI)))
      )
      {  if (symmetric)
         streamer->tab_sym_out = make_tab(iface.map_c)
      ;  else
         {  if (!(bits & MCLXIO_STREAM_ETC_AI))
            streamer->tab_col_out = make_tab(iface.map_c)
;if(0)fprintf(stderr, "%p x %p\n", (void*) iface.map_c->map, (void*) iface.map_c->tab)
;if(0)mcxHashStats(stdout, iface.map_c->map)
         ;  streamer->tab_row_out = make_tab(iface.map_r)
      ;  }
      }

      mcxHashFree(&(iface.map_c->map), mcxTingRelease, NULL)
   ;  if (!symmetric)
      mcxHashFree(&(iface.map_r->map), mcxTingRelease, NULL)

   ;  return mx
;  }