generated from freudenreichan/info2Praktikum-Wortsalat
funktion placeRandomLetters für createWordSalad ergänzt
This commit is contained in:
parent
ea373b6bad
commit
f407d5a36f
@ -115,6 +115,31 @@ int placeWord(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], wordPositi
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Places random letters into the
|
||||
// empty fields of the wordSalad
|
||||
void placeRandomLetters(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
for (i = 0; i < searchFieldLen; i++)
|
||||
{
|
||||
for (j = 0; i < searchFieldLen; j++)
|
||||
{
|
||||
if (salad[i][j])
|
||||
{
|
||||
if ((salad[i][j] < 'A') && (salad[i][j] > 'z'))
|
||||
{
|
||||
salad[i][j] = rand()%('Z' - 'A' + 1) + 'A';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Creates the word salad by placing words randomly and filling empty spaces
|
||||
// returnes the number of sucessfully placed words
|
||||
@ -144,6 +169,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
}
|
||||
}
|
||||
|
||||
placeRandomLetters(salad, searchFieldLen);
|
||||
|
||||
|
||||
return placedWords;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user