struct practice
This commit is contained in:
+7
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user