generated from freudenreichan/info2Praktikum-Wortsalat
Projekt fertig fertig
This commit is contained in:
parent
0aa55ef2d5
commit
5a6a3e5ac6
@ -15,21 +15,21 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
{
|
||||
int saladclone[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
||||
int wordsplacedcounter=0;
|
||||
for (int i=0;i<MAX_SEARCH_FIELD_LEN;i++){
|
||||
|
||||
for (int i=0;i<MAX_SEARCH_FIELD_LEN;i++){ //Feld 1 mit 0ern füllen
|
||||
for (int j=0;j<MAX_SEARCH_FIELD_LEN;j++) {
|
||||
saladclone[i][j] = 0;
|
||||
}
|
||||
}
|
||||
srand(time(NULL));
|
||||
|
||||
for (int i = 0;i < searchFieldLen; i++) { //Feld mit random Buchstaben füllen
|
||||
for (int i = 0;i < searchFieldLen; i++) { //Feld 2 mit random Buchstaben füllen
|
||||
for (int j = 0; j < searchFieldLen; j++) {
|
||||
salad[i][j] = 'A' + (rand() % 26);
|
||||
}
|
||||
}
|
||||
|
||||
//Array das mit der Anzahl der Wörter gefüllt wird
|
||||
int wordOrientation[wordCount];
|
||||
int wordOrientation[wordCount]; //Array das mit der Anzahl der Wörter gefüllt wird
|
||||
|
||||
for (int w = 0;w < wordCount; w++) { //Randomizer, ob Wort horizontal oder vertikal wird
|
||||
wordOrientation[w] = rand() % 2; //vertikal = 0, horizontal = 1
|
||||
@ -53,7 +53,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
if (col + wordLen > searchFieldLen) //erst wird überprüft, ob das Wort überlappt
|
||||
continue;
|
||||
|
||||
for (int i=0;i < wordLen; i++) {
|
||||
for (int i=0;i < wordLen; i++) { //es wird überprüft ob 1er im Feld 1 vorhanden sind
|
||||
if (saladclone[row][col + i]==1) {
|
||||
check=1;
|
||||
}
|
||||
@ -62,10 +62,10 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
|
||||
printf("Wort: %d,%d \n", row,col);
|
||||
|
||||
for (int i = 0;i < wordLen; i++) { //Wort wird in Spalte geschrieben
|
||||
for (int i = 0;i < wordLen; i++) { //Wort wird in Spalte geschrieben (Feld 2)
|
||||
salad[row][col + i] = word[i];
|
||||
|
||||
saladclone[row][col + i] = 1;
|
||||
saladclone[row][col + i] = 1; //Feld 1 wird mit 1ern gefüllt
|
||||
}
|
||||
wordPlaced = 1;
|
||||
wordsplacedcounter++;
|
||||
@ -75,7 +75,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
if (row + wordLen > searchFieldLen) //erst wird überprüft, ob das Wort überlappt
|
||||
continue;
|
||||
|
||||
for (int i=0;i < wordLen; i++) {
|
||||
for (int i=0;i < wordLen; i++) { //es wird überprüft ob 1er im Feld 1 vorhanden sind
|
||||
if (saladclone[row+i][col]==1) {
|
||||
check=1;
|
||||
}
|
||||
@ -84,10 +84,10 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
|
||||
printf("Wort: %d,%d \n", row,col);
|
||||
|
||||
for (int i = 0;i < wordLen; i++) { //Wort wird in Zeile geschrieben
|
||||
for (int i = 0;i < wordLen; i++) { //Wort wird in Zeile geschrieben (Feld 2)
|
||||
salad[row + i][col] = word[i];
|
||||
|
||||
saladclone[row+i][col] = 1;
|
||||
saladclone[row+i][col] = 1; //Feld 1 wird mit 1ern gefüllt
|
||||
}
|
||||
wordPlaced = 1;
|
||||
wordsplacedcounter++;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user