Compare commits
No commits in common. "5fbc71cf038af048016973f1451f7bd9cb9a99e1" and "dc9b59395b2999754557c3a413e04aec1f05f782" have entirely different histories.
5fbc71cf03
...
dc9b59395b
@ -13,48 +13,11 @@
|
|||||||
// Creates the word salad by placing words randomly and filling empty spaces
|
// Creates the word salad by placing words randomly and filling empty spaces
|
||||||
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
||||||
{
|
{
|
||||||
// set seed for random number generator
|
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
int r, c;
|
|
||||||
|
|
||||||
//Gesamtes Feld auf 0 setzen
|
|
||||||
for (r=0; r < searchFieldLen; r++) {
|
|
||||||
for (c=0; c < searchFieldLen; c++) {
|
|
||||||
salad [r][c] = EMPTY_CHAR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Wörter zufällig horizontal oder vertikal platzieren
|
|
||||||
enum Richtung {HORIZONTAL,VERTIKAL}; //0;1
|
|
||||||
enum Richtung dir;
|
|
||||||
dir = (rand() % 2 == 0) ? HORIZONTAL : VERTIKAL;
|
|
||||||
//Schleife, die das Setzen für alle Wörter durchführt, Zufällig horizontal(0) oder vertikal(1), an zufällige Stelle
|
|
||||||
//Prüfen, ob das Wort von der Länge her ins Feld passt
|
|
||||||
|
|
||||||
|
|
||||||
//Felder, in denen keine Wörter stehen, werden mit zufälligen Buchstaben befüllt
|
|
||||||
for (r=0; r < searchFieldLen; r++) {
|
|
||||||
for (c=0; c < searchFieldLen; c++) {
|
|
||||||
if (salad[r][c] == EMPTY_CHAR) {
|
|
||||||
salad [r][c] = 'A' + (rand()% 26);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints the word salad to console
|
// Prints the word salad to console
|
||||||
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
|
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
|
||||||
{
|
{
|
||||||
int r, c;
|
|
||||||
|
|
||||||
//Ausgabe des gesamten Feldes
|
|
||||||
for (r=0; r < searchFieldLen; r++) {
|
|
||||||
for (c=0; c < searchFieldLen; c++) {
|
|
||||||
printf("%c ", salad[r][c]);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,9 +13,6 @@
|
|||||||
// Creates the word salad by placing words randomly and filling empty spaces
|
// Creates the word salad by placing words randomly and filling empty spaces
|
||||||
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
||||||
{
|
{
|
||||||
// set seed for random number generator
|
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
int r, c;
|
int r, c;
|
||||||
|
|
||||||
//Gesamtes Feld auf 0 setzen
|
//Gesamtes Feld auf 0 setzen
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user