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 ersterbuchstabe;
|
||||||
int erledigt;
|
int erledigt;
|
||||||
|
|
||||||
|
|
||||||
//salad befuellen mit "0"
|
//salad befuellen mit "0"
|
||||||
for (int i=0;i<searchFieldLen; i++){
|
for (int i=0;i<searchFieldLen; i++){
|
||||||
for (int ii=0;ii<searchFieldLen; ii++){
|
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 *trenner = " .;,";
|
||||||
char *token;
|
char *token;
|
||||||
char *enter = "\n";
|
char *enter = "\n";
|
||||||
char sorter[MAX_WORD_LEN];
|
|
||||||
|
|
||||||
//Zeilen auslesen und als ein String speichern
|
//Zeilen auslesen und als ein String speichern
|
||||||
while(fgets(zeile,MAX_LINE_LEN, file) != NULL){
|
while(fgets(zeile,MAX_LINE_LEN, file) != NULL){
|
||||||
@ -36,6 +35,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
token = strtok(NULL, trenner);
|
token = strtok(NULL, trenner);
|
||||||
counter ++;
|
counter ++;
|
||||||
}
|
}
|
||||||
|
inhalt[0]='\0';
|
||||||
|
|
||||||
for(int i=0;i<counter;i++){ //Schleife für nur Großbuchstaben
|
for(int i=0;i<counter;i++){ //Schleife für nur Großbuchstaben
|
||||||
for(int ii=0;ii<strlen(words[i]);ii++){
|
for(int ii=0;ii<strlen(words[i]);ii++){
|
||||||
@ -43,17 +43,6 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
//Test
|
||||||
for(int i =0;i<counter;i++){
|
for(int i =0;i<counter;i++){
|
||||||
printf("%s\n", words[i]);
|
printf("%s\n", words[i]);
|
||||||
|
|||||||
Binary file not shown.
@ -3,6 +3,7 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "graphicalGame.h"
|
#include "graphicalGame.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define MAX_NUMBER_OF_WORDS 100
|
#define MAX_NUMBER_OF_WORDS 100
|
||||||
#define SALAD_SIZE 20
|
#define SALAD_SIZE 20
|
||||||
@ -27,10 +28,22 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
unsigned int placedWords = 0;
|
unsigned int placedWords = 0;
|
||||||
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad
|
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
|
// Read words from file and store in 'words' array
|
||||||
wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS);
|
wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS);
|
||||||
fclose(file);
|
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
|
// Create the word salad by placing words into grid
|
||||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
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