コード例 #1
0
ファイル: hide.c プロジェクト: absmall/wordsearch
void wordsearch_fit( word_search_t *ws )
{
	int i;

	// We don't need strong randomness, reproducibility is better
	srand(0);

	// Sort words by length to fit longest first
	qsort( ws->words, ws->word_count, sizeof(wchar_t *), compare );

	// Fit each word
	for( i = 0; i < ws->word_count; i ++ ) {
		fit_word( ws, ws->words[i] );
	}
}
コード例 #2
0
ファイル: scrab.c プロジェクト: pythontech/wordgames
/*----------------------------------------------------------------------
 *	Find words which fit in the given position
 *----------------------------------------------------------------------*/
void find_words(void)
{
  char bused[MAXBLANK+1];
  Dscan ds = Dscan_open(dict, len);
  const char *word;
  int pos;
  Map *allow = allowed[play.row]+play.col;
  char *line = board[play.row]+play.col;

  while ((word = Dscan_read(ds)) != NULL) {
    strcpy(play.word, word);
    if ((pos = fit_word(line, allow, bused)) == len) {
      strcpy(play.bword, play.word);
      consider_word(bused);
    }else{
      Dscan_skip(ds, pos);
    }
  }
  Dscan_close(ds);
}