generated from freudenreichan/info2Praktikum-Wortsalat
TestAnpassungen
This commit is contained in:
parent
4d796b0dcc
commit
fadba480fd
@ -29,6 +29,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
int ersterbuchstabe;
|
||||
int erledigt;
|
||||
|
||||
|
||||
//salad befuellen mit "0"
|
||||
for (int i=0;i<searchFieldLen; i++){
|
||||
for (int ii=0;ii<searchFieldLen; ii++){
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -15,7 +15,6 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
char *trenner = " .;,";
|
||||
char *token;
|
||||
char *enter = "\n";
|
||||
char sorter[MAX_WORD_LEN];
|
||||
|
||||
//Zeilen auslesen und als ein String speichern
|
||||
while(fgets(zeile,MAX_LINE_LEN, file) != NULL){
|
||||
@ -36,23 +35,13 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
token = strtok(NULL, trenner);
|
||||
counter ++;
|
||||
}
|
||||
inhalt[0]='\0';
|
||||
|
||||
for(int i=0;i<counter;i++){ //Schleife für nur Großbuchstaben
|
||||
for(int ii=0;ii<strlen(words[i]);ii++){
|
||||
words[i][ii] = toupper(words[i][ii]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<counter-1;i++){ //nach Groesse sortieren
|
||||
for(int ii=0;ii<counter-1-i;ii++){
|
||||
if(strlen(words[ii]) < strlen(words[ii+1])) {
|
||||
strncpy(sorter,words[ii],MAX_WORD_LEN);
|
||||
strncpy(words[ii],words[ii+1], MAX_WORD_LEN);
|
||||
strncpy(words[ii+1],sorter, MAX_WORD_LEN);
|
||||
}
|
||||
strcpy(sorter,"");
|
||||
}
|
||||
}
|
||||
|
||||
//Test
|
||||
for(int i =0;i<counter;i++){
|
||||
|
||||
Binary file not shown.
@ -3,6 +3,7 @@
|
||||
#include "input.h"
|
||||
#include "game.h"
|
||||
#include "graphicalGame.h"
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_NUMBER_OF_WORDS 100
|
||||
#define SALAD_SIZE 20
|
||||
@ -27,10 +28,22 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int placedWords = 0;
|
||||
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad
|
||||
char sorter[MAX_WORD_LEN];
|
||||
|
||||
// Read words from file and store in 'words' array
|
||||
wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS);
|
||||
fclose(file);
|
||||
|
||||
for(int i=0;i<wordCount-1;i++){ //nach Groesse sortieren
|
||||
for(int ii=0;ii<wordCount-1-i;ii++){
|
||||
if(strlen(words[ii]) < strlen(words[ii+1])) {
|
||||
strncpy(sorter,words[ii],MAX_WORD_LEN);
|
||||
strncpy(words[ii],words[ii+1], MAX_WORD_LEN);
|
||||
strncpy(words[ii+1],sorter, MAX_WORD_LEN);
|
||||
}
|
||||
strcpy(sorter,"");
|
||||
}
|
||||
}
|
||||
// Create the word salad by placing words into grid
|
||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||
|
||||
|
||||
Binary file not shown.
BIN
Start_Windows/runTests.exe
Normal file
BIN
Start_Windows/runTests.exe
Normal file
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user