start der createWordSalat funktion
This commit is contained in:
parent
3c68ced8ab
commit
c5501c1bd3
@ -3,6 +3,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#define MAX_RAND_TRIES_PER_WORD 10
|
#define MAX_RAND_TRIES_PER_WORD 10
|
||||||
#define EMPTY_CHAR 0
|
#define EMPTY_CHAR 0
|
||||||
|
|
||||||
@ -13,6 +14,28 @@
|
|||||||
// Creates the word salad by placing words randomly and filling empty spaces
|
// Creates the word salad by placing words randomly and filling empty spaces
|
||||||
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
||||||
{
|
{
|
||||||
|
for(wordCount;wordCount>0;wordCount--)
|
||||||
|
{
|
||||||
|
size_t platzbedarf = strlen(words[wordCount-1]);
|
||||||
|
if (platzbedarf >= searchFieldLen)
|
||||||
|
{
|
||||||
|
printf("%s konnte nicht eingefuegt werden da es groeßer als das Feld ist",words[wordCount-1]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
do
|
||||||
|
{
|
||||||
|
srand(time(NULL));
|
||||||
|
short max = searchFieldLen - platzbedarf;
|
||||||
|
short position = rand() % (max +1);
|
||||||
|
srand(time(NULL));
|
||||||
|
short waagrecht = rand()%2;
|
||||||
|
|
||||||
|
|
||||||
|
}while(1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user