diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..7f0798933 Binary files /dev/null and b/.DS_Store differ diff --git a/projects/.DS_Store b/projects/.DS_Store new file mode 100644 index 000000000..349845414 Binary files /dev/null and b/projects/.DS_Store differ diff --git a/projects/alabidif/.DS_Store b/projects/alabidif/.DS_Store new file mode 100644 index 000000000..b765d92ad Binary files /dev/null and b/projects/alabidif/.DS_Store differ diff --git a/projects/alabidif/quiz/.DS_Store b/projects/alabidif/quiz/.DS_Store new file mode 100644 index 000000000..44f6a2084 Binary files /dev/null and b/projects/alabidif/quiz/.DS_Store differ diff --git a/projects/alabidif/quiz/Makefile b/projects/alabidif/quiz/Makefile new file mode 100644 index 000000000..5ae60ffe9 --- /dev/null +++ b/projects/alabidif/quiz/Makefile @@ -0,0 +1,8 @@ +CFLAGS= -Wall -fpic -coverage -lm -std=c99 + +testme: + -gcc -o testme -g testme.c $(CFLAGS) + -testme >> testresults.out + -gcov testme.c -b -f >> testresults.out +clean: + -rm -f testme *.gcov *.gcda *.gcno *.o \ No newline at end of file diff --git a/projects/alabidif/quiz/randomstring.pdf b/projects/alabidif/quiz/randomstring.pdf new file mode 100644 index 000000000..18978259a Binary files /dev/null and b/projects/alabidif/quiz/randomstring.pdf differ diff --git a/projects/alabidif/quiz/testme.c b/projects/alabidif/quiz/testme.c new file mode 100644 index 000000000..06ccc9409 --- /dev/null +++ b/projects/alabidif/quiz/testme.c @@ -0,0 +1,65 @@ +#include +#include +#include +#include + +char inputChar() +{ + // TODO: rewrite this function + int randInt = (rand() % 95) + 32; + char randChar = (char) randInt; + return randChar; +} + +char *inputString() +{ + // TODO: rewrite this function + char randString[6]; + for (int i = 0; i < 5; i++) { + randString[i] = (rand() % 16) + 101; + } + randString[5]='\0'; + char *inString = randString; + return inString; +} + +void testme() +{ + int tcCount = 0; + char *s; + char c; + int state = 0; + while (1) + { + tcCount++; + c = inputChar(); + s = inputString(); + printf("Iteration %d: c = %c, s = %s, state = %d\n", tcCount, c, s, state); + + if (c == '[' && state == 0) state = 1; + if (c == '(' && state == 1) state = 2; + if (c == '{' && state == 2) state = 3; + if (c == ' '&& state == 3) state = 4; + if (c == 'a' && state == 4) state = 5; + if (c == 'x' && state == 5) state = 6; + if (c == '}' && state == 6) state = 7; + if (c == ')' && state == 7) state = 8; + if (c == ']' && state == 8) state = 9; + if (s[0] == 'r' && s[1] == 'e' + && s[2] == 's' && s[3] == 'e' + && s[4] == 't' && s[5] == '\0' + && state == 9) + { + printf("error "); + exit(200); + } + } +} + + +int main(int argc, char *argv[]) +{ + srand(time(NULL)); + testme(); + return 0; +}