|
|
@ -30,14 +30,63 @@ int* randomNumber() { |
|
|
|
|
|
|
|
//------------Math_quiz_begin------------ |
|
|
|
|
|
|
|
void math_choose_question(int num) { |
|
|
|
void math_choose_question(int num1) { |
|
|
|
char choose [][100] = { |
|
|
|
"what is 1 + 1\n", |
|
|
|
"what is 4 + 3\n", |
|
|
|
"what is 4 * 8\n", |
|
|
|
"what is ((6*8)/4)+2\n" |
|
|
|
"what is ((6*8)/4)+2\n", |
|
|
|
"what is 1 + 3\n", |
|
|
|
"what is 5 + 3\n", |
|
|
|
"what is 4 * 10\n", |
|
|
|
"what is ((6*2)/2)+2\n", |
|
|
|
|
|
|
|
"what is 5-7+12\n", //10 |
|
|
|
"what is 4 + 3 * 2\n",//10 |
|
|
|
"what is 4 * 8 - 10\n", //22 |
|
|
|
"what is ((6*6)/4)+3\n", //12 |
|
|
|
"what is 1 + 21\n",//22 |
|
|
|
"what is 5 + 75\n",//80 |
|
|
|
"what is 4 * 11\n",//44 |
|
|
|
"what is 56 * 0\n",// 0 |
|
|
|
|
|
|
|
"what is 1 + 5\n", //6 |
|
|
|
"what is 4 + 90\n",//94 |
|
|
|
"what is 4 * 4\n",//16 |
|
|
|
"what is ((6*4)/4)\n", //6 |
|
|
|
"what is 56 + 3\n",//59 |
|
|
|
"what is 5 + 5\n",//10 |
|
|
|
"what is 4 * 5\n", //20 |
|
|
|
"what is ((6*2)/2)+5\n",//11 |
|
|
|
|
|
|
|
"what is 23 + 2\n",//25 |
|
|
|
"what is 4 + 23\n",//27 |
|
|
|
"what is 3 * 7\n",//21 |
|
|
|
"what is ((6*7)/6)\n",//7 |
|
|
|
"what is 1 + 85\n",//86 |
|
|
|
"what is 5 + 45\n",//50 |
|
|
|
"what is 4 * 20\n",//80 |
|
|
|
"what is (5/2)*4\n"//10 |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
printf("%s", choose[num]); |
|
|
|
srand(time(NULL)); |
|
|
|
int k = 0, p; |
|
|
|
static int arr[32]; |
|
|
|
while(k<32) { |
|
|
|
int num = rand() % 32; |
|
|
|
for (p = 0; p < k; p++) { |
|
|
|
if (arr[p] == num) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (p == k) { |
|
|
|
arr[k++] = num; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int num2 = arr[num1]; |
|
|
|
printf("%s", choose[num2]); |
|
|
|
} |
|
|
|
|
|
|
|
int math_answer(int num1) { |
|
|
@ -45,34 +94,88 @@ int math_answer(int num1) { |
|
|
|
2, |
|
|
|
7, |
|
|
|
32, |
|
|
|
14 |
|
|
|
14, |
|
|
|
4, |
|
|
|
8, |
|
|
|
40, |
|
|
|
8, |
|
|
|
10, |
|
|
|
10, |
|
|
|
22, |
|
|
|
12, |
|
|
|
22, |
|
|
|
80, |
|
|
|
44, |
|
|
|
0, |
|
|
|
6, |
|
|
|
94, |
|
|
|
16, |
|
|
|
6, |
|
|
|
59, |
|
|
|
10, |
|
|
|
20, |
|
|
|
11, |
|
|
|
|
|
|
|
25, |
|
|
|
27, |
|
|
|
21, |
|
|
|
7, |
|
|
|
86, |
|
|
|
50, |
|
|
|
80, |
|
|
|
10 |
|
|
|
}; |
|
|
|
return ans[num1]; |
|
|
|
srand(time(NULL)); |
|
|
|
int k = 0, p; |
|
|
|
static int arr[32]; |
|
|
|
while(k<32) { |
|
|
|
int num = rand() % 32; |
|
|
|
for (p = 0; p < k; p++) { |
|
|
|
if (arr[p] == num) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (p == k) { |
|
|
|
arr[k++] = num; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int num2 = arr[num1]; |
|
|
|
return ans[num2]; |
|
|
|
} |
|
|
|
|
|
|
|
void math_display_choice(){ |
|
|
|
int user_answer, ques_ans; |
|
|
|
while (ques_ans != 4) { |
|
|
|
printf("Choose a number between 1 and 4: "); |
|
|
|
int user_answer, ques_ans,repeat = 0; |
|
|
|
|
|
|
|
printf("Choose a number between 1 and 4(game ends with invalid number or wrong answer): "); |
|
|
|
scanf("%d", &user_answer); |
|
|
|
user_answer = user_answer-1; |
|
|
|
int quiz_answer = math_answer(user_answer); |
|
|
|
while (user_answer != 4 || repeat) { |
|
|
|
quiz_answer = math_answer(user_answer); |
|
|
|
switch(user_answer){ |
|
|
|
case 0: case 1: case 2: case 3: |
|
|
|
math_choose_question(user_answer); |
|
|
|
printf("Answer: "); |
|
|
|
scanf("%d", &ques_ans); |
|
|
|
repeat =1; |
|
|
|
break; |
|
|
|
default: |
|
|
|
printf("Invalid choice!\n"); |
|
|
|
break; |
|
|
|
} |
|
|
|
int quiz_answer = math_answer(user_answer); |
|
|
|
|
|
|
|
if(quiz_answer == ques_ans){ |
|
|
|
printf("Correct!\n"); |
|
|
|
} else { |
|
|
|
printf("Wrong!\n"); |
|
|
|
break; |
|
|
|
} |
|
|
|
if (repeat) { |
|
|
|
repeat = 0; |
|
|
|
printf("Choose a number between 1 and 4(game ends with invalid number or wrong answer): "); |
|
|
|
scanf("%d", &user_answer); |
|
|
|
user_answer = user_answer-1; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -390,7 +493,7 @@ void e_printout(char print_out_questn[][100], char questions[][100],int randArr[ |
|
|
|
|
|
|
|
for(int i = 0; i < 4; i++) { |
|
|
|
int rNum = randArr[i]; |
|
|
|
printf("[%d] Guess is the correct word for this anagram: %s\n", i+1, print_out_questn[rNum]); |
|
|
|
printf("[%d] Guess the correct word for this anagram: %s\n", i+1, print_out_questn[rNum]); |
|
|
|
printf("Answer: "); |
|
|
|
scanf("%s", usr_ans); |
|
|
|
for(int j = 0; j < strlen(usr_ans); j++) { |
|
|
|