generated from freudenreichan/info2Praktikum-Wortsalat
ausbesserungen aus stunde
This commit is contained in:
parent
ed22736f68
commit
6027c2a061
@ -107,22 +107,26 @@ int checkIfPositionIsFree(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]
|
||||
int placeWord(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], wordPosition position, const char currentWord[], unsigned int currentWordLen, unsigned int serchFieldLen)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
|
||||
if (position.alignment == HORIZONTAL)
|
||||
{
|
||||
|
||||
for (i = position.startingCell; (i < serchFieldLen) && (i < currentWordLen); i++)
|
||||
for (i = position.startingCell; (i < serchFieldLen) || (j < currentWordLen); i++)
|
||||
{
|
||||
salad[position.rowOrColumn][i] = currentWord[i];
|
||||
salad[position.rowOrColumn][i] = currentWord[j];
|
||||
printf("%c",currentWord[j]);
|
||||
j++;
|
||||
}
|
||||
salad[position.rowOrColumn][i] = '\0';
|
||||
}
|
||||
else if (position.alignment == VERTIKAL)
|
||||
{
|
||||
for (i = position.startingCell; (i < serchFieldLen) && (i < currentWordLen); i++)
|
||||
for (i = position.startingCell; (i < serchFieldLen) || (j < currentWordLen); i++)
|
||||
{
|
||||
salad[i][position.rowOrColumn] = currentWord[i];
|
||||
salad[i][position.rowOrColumn] = currentWord[j];
|
||||
printf("%c",currentWord[j]);
|
||||
j++;
|
||||
}
|
||||
salad[i][position.rowOrColumn] = '\0';
|
||||
}
|
||||
@ -165,6 +169,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
|
||||
srand(time(NULL));
|
||||
initializeWordsalad(salad, searchFieldLen);
|
||||
showWordSalad(salad, searchFieldLen);
|
||||
|
||||
for (i = 1; i <= wordCount; i++)
|
||||
{
|
||||
@ -178,7 +183,11 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
|
||||
if (positionFound)
|
||||
{
|
||||
strcpy(currentWord, "\0");
|
||||
strcpy(currentWord, words[i-1]);
|
||||
|
||||
printf("%d, %d, %d \n", currentWordPosition.alignment, currentWordPosition.rowOrColumn, currentWordPosition.startingCell);
|
||||
printf("%s\n", currentWord);
|
||||
placedWords += placeWord(salad, currentWordPosition, currentWord, strlen(currentWord), searchFieldLen);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user