From b1117af2d9167204585be3671ecabebadc1de1f5 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sat, 24 Sep 2022 12:30:31 -0400 Subject: centralized formating header file --- README.md | 16 ++++++++-------- format.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ testData.h | 2 +- 3 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 format.h diff --git a/README.md b/README.md index a2f6d57..1bdc876 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ programing as well as basic algorithms. The project requires that we (the students) create a C library which doesn't rely on third party libraries to do the following things: -| Task | filename | Level | -| :------------------------------------ | :---------- | :------- | -| Spot characters in a string | `TODO` | Easy | -| Identify words which are palindromes | `TODO` | Easy | -| Calculate sines (using series) | `TODO` | Medium | -| Calculate cosines (using series) | `TODO` | Medium | -| Matrix addition | `TODO` | Hard* | -| Matrix multiplication | `TODO` | Hard* | +| Task | filename | Level | +| :------------------------------------ | :----------------- | :------- | +| Spot characters in a string | `findChar.h` | Easy | +| Identify words which are palindromes | `findPalindrome.h` | Easy | +| Calculate sines (using series) | `sine.h` | Medium | +| Calculate cosines (using series) | `cosine.h` | Medium | +| Matrix addition | `TODO` | Hard* | +| Matrix multiplication | `TODO` | Hard* | *This is the first programing APP. The word Hard is used very liberaly here. diff --git a/format.h b/format.h new file mode 100644 index 0000000..2f9c1b4 --- /dev/null +++ b/format.h @@ -0,0 +1,56 @@ +/* format.h + * ---------------------------------------------------------------------------- + * 'THE BEER-WARE LICENSE' (Revision 42): + * wrote this file. As long as you retain this notice + * you can do whatever you want with this stuff. If we meet some day, and you + * think this stuff is worth it, you can buy me a beer in return. + * Benjamin Chausse + * ---------------------------------------------------------------------------- + */ + +#define TRUE 1 +#define FALSE 0 +#define COUNT_OF( arr) (sizeof(arr)/sizeof(0[arr])) + +// Conversion table between uppercase and lowercase +const char caps[2][26] = { + {'A','B','C','D','E','F','G','H','I','J','K','L','M', + 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}, + {'a','b','c','d','e','f','g','h','i','j','k','l','m', + 'n','o','p','q','r','s','t','u','v','w','x','y','z'} +}; + +// Convert every character to lowercase +char * lower(char *str){ + int len = COUNT_OF(str); + for (int i=0; i sis, heightened, minim // - Spaces before the words -> sis, unholly, pop // - Non latin alphabet (greek & russian) -char *word[] = { +char *wrd[] = { "abba", "betrothed", "deified", "elevation", "genesis", "kayak", "murdum", " pop", "relinquish", "stats", "thirst", "abhorrent", "accentuated", "agoraphobia", " aibohphobia", "anemia", "bIb", "bittersweet", "bob", -- cgit v1.2.3