generated from freudenreichan/info2Praktikum-Wortsalat
Warning sind verschwunden, Parameter und Datentypen angepasst
This commit is contained in:
parent
ec60cd9994
commit
65a5645f2f
@ -36,9 +36,9 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN])
|
||||
{
|
||||
printf("\nWordSalad:\n");
|
||||
for(int i=0; i < MAX_SEARCH_FIELD_LEN; i++)
|
||||
for(unsigned int i=0; i < MAX_SEARCH_FIELD_LEN; i++)
|
||||
{
|
||||
for(int j=0; j< MAX_SEARCH_FIELD_LEN; j++)
|
||||
for(unsigned int j=0; j< MAX_SEARCH_FIELD_LEN; j++)
|
||||
{
|
||||
printf("%c\t", salad[i][j]);
|
||||
}
|
||||
@ -70,8 +70,8 @@ int fillSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned i
|
||||
{
|
||||
int addedWords = 0;
|
||||
// empties salad
|
||||
for(unsigned int i = 0; i < searchFieldLen; i++) {
|
||||
for(unsigned int j = 0; j < searchFieldLen; j++) {
|
||||
for(unsigned int i = 0; i < MAX_SEARCH_FIELD_LEN; i++) {
|
||||
for(unsigned int j = 0; j < MAX_SEARCH_FIELD_LEN; j++) {
|
||||
salad[i][j] = '\0';
|
||||
}
|
||||
}
|
||||
@ -114,7 +114,7 @@ int fillSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned i
|
||||
} else {
|
||||
// vertically
|
||||
int col = rand() % searchFieldLen;
|
||||
int wordLen = strlen(words[numWord]);
|
||||
unsigned int wordLen = strlen(words[numWord]);
|
||||
if(wordLen <= searchFieldLen) {
|
||||
int startRow = rand() % (searchFieldLen - wordLen + 1);
|
||||
int canPlace = 1;
|
||||
@ -230,18 +230,13 @@ void fillWordinColumn(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], un
|
||||
|
||||
|
||||
// if emptyPlaces, fill these with random letters
|
||||
void fillRandom(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN])
|
||||
{
|
||||
for(int j=0; j < MAX_SEARCH_FIELD_LEN; j++)
|
||||
{
|
||||
for(int h= 0; h < MAX_SEARCH_FIELD_LEN; h++)
|
||||
{
|
||||
if(salad[j][h] == '\0')
|
||||
{
|
||||
int num = rand()%(26 - 1 + 1) + 1;
|
||||
char letter = 64 + num;
|
||||
salad[j][h] = letter;
|
||||
void fillRandom(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]) {
|
||||
for (int j = 0; j < MAX_SEARCH_FIELD_LEN; j++) {
|
||||
for (int h = 0; h < MAX_SEARCH_FIELD_LEN; h++) {
|
||||
if (salad[j][h] == '\0') {
|
||||
char letter = 'A' + rand() % 26; // 0–25 → 'A'–'Z'
|
||||
salad[j][h] = letter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user