struct practice

This commit is contained in:
2026-05-30 17:57:52 +02:00
parent 42c08d947f
commit c737f8ab0f
3 changed files with 169 additions and 3 deletions
+7 -3
View File
@@ -22,7 +22,10 @@ okay dit werkt nu omzetten naar strings
/* return 1 if word1 < word 2*/
int compareword(char word1[], char word2[]) {
for (int i = 0; i < WORDLENGTH; i++) {
if (word1[i] < word2[i]) {
if (word1[i] == word2[i]) {
//it should continue
}
else if (word1[i] < word2[i]) {
printf("%s is larger than %s\n", word1, word2);
return 1;
}
@@ -33,7 +36,6 @@ int compareword(char word1[], char word2[]) {
return 0;
}
/* eerst gewone bubblesort weer doen */
int mybubblesort(char inputarr[WORDS][WORDLENGTH]) {
for (int i = 0; i < WORDS - 1; i++) { // voor elk woord
@@ -60,9 +62,11 @@ int mybubblesort(char inputarr[WORDS][WORDLENGTH]) {
int main() {
char mytest[16][64] = {"pear", "watermelon", "apple", "banana", "cantaloupe", "Elephant", "Zebra"};
char mytest[16][64] = {"pear", "watermelon", "aap", "apple", "banana", "cantaloupe", "Elephant", "Zebra"};
srand(time(NULL));
mybubblesort(mytest);
return 0;
}