diff --git a/P05_TicTacToe/work/sorter/a.out b/P05_TicTacToe/work/sorter/a.out new file mode 100644 index 0000000..e69de29 diff --git a/P05_TicTacToe/work/sorter/sorter b/P05_TicTacToe/work/sorter/sorter new file mode 100755 index 0000000..b1f699f Binary files /dev/null and b/P05_TicTacToe/work/sorter/sorter differ diff --git a/P05_TicTacToe/work/sorter/sorter.c b/P05_TicTacToe/work/sorter/sorter.c new file mode 100644 index 0000000..fb1d18d --- /dev/null +++ b/P05_TicTacToe/work/sorter/sorter.c @@ -0,0 +1,62 @@ +#include +#include +#define numWords 10 +#define lenWords 20 + +int toupper(int ch); + +int main(void) +{ + char words[numWords][lenWords] = {0}; + int readFinished = 0; + for(int i = 0; i < numWords; i++){ + char word[lenWords] = {}; + if(readFinished == 0){ + int newWord = 0; + while(newWord == 0 && readFinished == 0){ + printf("%d. Next Word: ", i); + scanf("%s", word); + for(int k = 0; k < lenWords; k++) + { + word[k] = toupper(word[k]); + } + if(strcmp("ZZZ", word) == 0){ + readFinished = 1; + printf("Finished reading...\n"); + } + else{ + newWord = 1; + for(int j = 0; j < i; j++){ + if(strcmp(word, words[j]) == 0){ + newWord = 0; + printf("Word was already in List.\n"); + } + + } + if(newWord == 1){ + strcpy(words[i], word); + } + } + + } + + } + } + + char temp[lenWords]; + for(int i=0;i0){ + strcpy(temp,words[i]); + strcpy(words[i],words[j]); + strcpy(words[j],temp); + } + } + + + printf("Sorted Words:\n"); + for(int i = 0; i < numWords; i++){ + printf("%s\n", words[i]); + } + +}