diff --git a/src/main/quizproject.c b/src/main/quizproject.c index a4b4c76..cf9f756 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -11,9 +11,9 @@ char answers[NUM_QUESTIONS] = {'B', 'A', 'A','B','A'}; int* randomNumber() { srand(time(NULL)); int k = 0, p; - static int arr[13]; - while(k<13){ - int num =rand()%13; + static int arr[100]; + while(k<100){ + int num =rand()%100; for (p = 0; p < k; p++){ if(arr[p]==num){ break; @@ -130,7 +130,7 @@ void e_ask_questions(void) { int* randChar = randomNumber(); int charArr[7]; int p1 = 0; - for(int k = 0; k < 13; k++) { + for(int k = 0; k < 100; k++) { if (randChar[k] < 7) { charArr[p1] = randChar[k]; p1++; @@ -250,7 +250,15 @@ void guess_word_questions() { "challenge" }; int* randArr0 = randomNumber(); - print_guess_word_question (guess_words, guess_solution,word_guessed, randArr0); + int arr0[13]; + int p = 0; + for(int i = 0; i < 100; i++){ + if(randArr0[i] < 13){ + arr0[p] = randArr0[i]; + p++; + } + } + print_guess_word_question (guess_words, guess_solution,word_guessed, arr0); } @@ -300,14 +308,34 @@ void print_guess_word_question (char guessWord[][100], char guessSolution[][100] } -void e_printout() { +void e_printout(char print_out_questn[][100], char questions[][100]) { printf("\t\t---------------------------Round5-----------------------------\n\n"); printf("\t\t >>You are represented with an Anagram in each question.<<\n"); printf(" >>Determine what word it is.<<\n\n"); printf("\t\t-------------------------------------------------------------\n\n"); + char usr_ans[100]; + + for(int i = 0; i < 4; i++) { + printf("[%d] Guess is the correct word for this anagram: %s\n", i+1, print_out_questn[i]); + printf("Answer: "); + scanf(" %s", usr_ans); + int k = 0; + for (int j = 0; j < strlen(print_out_questn[i]); j ++){ + if(usr_ans[j] == questions[i][j]) { + k++; + } + + } + if (k == strlen(print_out_questn[i]) && strlen(usr_ans) == strlen(print_out_questn[i])) { + printf("Correct!\n"); + + } else { + printf("Wrong!\n"); + } + } } @@ -321,10 +349,37 @@ void e_anagram_questions() { "progress" }; + char print_questions[100][100]; + int *charNum = randomNumber(); + char arr[100]; + for (int i = 0; i < 6; i++) { + for(int j = 0; j < 100; j++) { + arr[j] = questions[i][j]; + if (questions[i][j] == '\0') { + break; + } + } + //random array to mix letters + int len = (int)strlen(arr); + int charArr[len]; + int p = 0; + for(int l = 0; l < 100; l++) { + if (charNum[l] < len) { + charArr[p] = charNum[l]; + p++; + } + } + int randNum, f=0; + for(int k = 0; k < strlen(arr); k++){ + randNum = charArr[k]; + print_questions[i][f] = arr[randNum]; + f++; + } + } - e_printout(); + e_printout(print_questions,questions); } @@ -601,7 +656,15 @@ void ask_questions(void) { }; int* randArr = randomNumber(); - looping(questions, possible_options, answers, randArr); + int arr[11]; + int p = 0; + for(int i = 0; i < 100; i++){ + if(randArr[i] < 11){ + arr[p] = randArr[i]; + p++; + } + } + looping(questions, possible_options, answers, arr); } @@ -615,7 +678,7 @@ void ask_hard_questions(void) { int *lessFive = randomNumber(); int arr[5]; int p = 0; - for(int i = 0; i < 13; i++){ + for(int i = 0; i < 100; i++){ if(lessFive[i] < 5){ arr[p] = lessFive[i]; p++; diff --git a/src/main/quizproject.h b/src/main/quizproject.h index a82b9d6..678fd25 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -47,7 +47,7 @@ void e_printout_r3 (char [][100], char [][100]); int track_r2_score = 0; void guess_word_questions(void); void print_guess_word_question (char [][100], char [][100],char [][100], int []); -void e_printout(void); +void e_printout(char [][100], char [][100]); void e_anagram_questions(void); //----smart_brain_header_end-------