Ueberlappung zweier Woerter ist moeglich

This commit is contained in:
silvana884 2025-11-06 13:29:10 +01:00
parent 9624270bc3
commit 6b30eb3145

View File

@ -98,9 +98,11 @@ int fillSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned i
int startCol = rand() % (searchFieldLen - wordLen + 1);
int canPlace = 1;
for(unsigned int i = 0; i < wordLen; i++) { //checks if word fits
if(salad[row][startCol + i] != '\0') {
canPlace = 0;
if(salad[row][startCol + i] != '\0') { //wird nicht geplaced, wenn salad an der Stelle ungleich Buchstabe in words an der Stelle
if(salad[row][startCol + i] != words[numWord][i]) {
canPlace = 0;
break;
}
}
}
if(canPlace) { //word fits and is inserted
@ -120,8 +122,10 @@ int fillSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned i
int canPlace = 1;
for(unsigned int i = 0; i < wordLen; i++) {
if(salad[startRow + i][col] != '\0') {
if(salad[startRow + i][col] != words[numWord][i]) {
canPlace = 0;
break;
}
}
}
if(canPlace) {
@ -240,3 +244,4 @@ void fillRandom(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]) {
}
}
}