forked from freudenreichan/info2Praktikum-Wortsalat
finished Programm
This commit is contained in:
1 parent
cbfd7d5071
commit
f81b98bc1c
2 files changed
+22
-12
No files matched your search
+8
-8
@@ -19,12 +19,12 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
//befüllen des Arrays mit '\0'
|
||||
for(unsigned int i = 0; i < searchFieldLen; i++)
|
||||
{
|
||||
for(unsigned int j = 0; j < searchFieldLen; i++)
|
||||
for(unsigned int j = 0; j < searchFieldLen; j++)
|
||||
{
|
||||
salad[i][j] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//erstellen von Richtungsvektoren
|
||||
int dx[] = {1, 0};
|
||||
int dy[] = {0, 1};
|
||||
@@ -37,7 +37,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
{
|
||||
return FEHLER_LAENGE_WORT;
|
||||
}
|
||||
|
||||
|
||||
int placed = 0;
|
||||
int attempts = 0;
|
||||
|
||||
@@ -48,8 +48,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
int zeile = rand() % searchFieldLen;
|
||||
int spalte = rand() % searchFieldLen;
|
||||
|
||||
if(dir == 0 && (zeile + laenge > searchFieldLen))
|
||||
if(dir == 1 && (spalte + laenge > searchFieldLen))
|
||||
if ((dir == 0 && (zeile + laenge > searchFieldLen)) ||
|
||||
(dir == 1 && (spalte + laenge > searchFieldLen)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
placed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!placed) //überprüft ob das Wort gesetzt wurde, wenn nicht Fehlerausgabe
|
||||
{
|
||||
return FEHLER_SETZEN;
|
||||
@@ -89,12 +89,12 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
{
|
||||
for(unsigned int j = 0; j < searchFieldLen; j++)
|
||||
{
|
||||
if(salad[i][j] == '\n')
|
||||
if(salad[i][j] == '\0')
|
||||
{
|
||||
salad[i][j] = 'A' + rand() % 26;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ERFOLG;
|
||||
return (int)wordCount;
|
||||
}
|
||||
Reference in new issue
Block a user