app.c |
| #include <stdio.h> #include <stdlib.h> #include "bst.h" void print_key(char *key){ printf("%s\n", key); } void uppercase_key(char *key){ int i; for(i = 0; i<strlen(key)+1; i++){ if(key[i]>96 && key[i]<123) key[i]-=32; } } void lowercase_key(char *key){ int i; for(i = 0; i<strlen(key)+1; i++){ if(key[i]>64 && key[i]<91) key[i]+=32; } } void format_key(char *key){ int i=0; if(key[i]>96 && key[i]<123) key[i]-=32; for(i = 1; i<strlen(key)+1; i++){ if(key[i]>64 && key[i]<91) key[i]+=32; } } int main(void){ bst b = bst_new(); printf("insert and inorder test\n"); b = bst_insert(b, "james"); b = bst_insert(b, "john"); b = bst_insert(b, "jason"); b = bst_insert(b, "luke"); b = bst_insert(b, "simon"); b = bst_insert(b, "amanda"); b = bst_insert(b, "vicki"); bst_inorder(b, print_key); printf("---\n"); printf("\npreorder test\n"); bst_preorder(b, print_key); printf("---\n"); printf("\ndelete test\n"); b = bst_delete(b, "simon"); bst_inorder(b, print_key); printf("---\n"); printf("\nto UpperCase test\n"); bst_inorder(b, uppercase_key); bst_inorder(b, print_key); printf("---\n"); printf("\nto Format test\n"); bst_inorder(b, format_key); bst_inorder(b, print_key); printf("---\n"); printf("\nto LowerCase test\n"); bst_inorder(b, lowercase_key); bst_inorder(b, print_key); printf("---\n"); return EXIT_SUCCESS; } |
James Little |