4. Simulate Multiple Recursion

Read（293） Label: multiple recursion, judge, for, func,

l  Problem

Please compile a program to answer the following 10 questions:

1. Which is the question that has the first answer b?

(a) 2; (b) 3; (c) 4; (d) 5; (e)6

2. The only consecutive questions which have same answers are:

(a) 2, 3; (b) 3, 4; (c) 4, 5; (d) 5, 6; (e) 6, 7;

3. Which is the question whose answer is the same as the answer to this question?

(a) 1; (b) 2; (c) 4; (d) 7; (e) 6

4. The number of questions with the answer a is:

(a) 0; (b) 1; (c) 2; (d) 3; (e) 4

5. Which is the question whose answer is the same as the answer to this question?

(a) 10; (b) 9; (c) 8; (d) 7; (e) 6

6. What is the answer to the questions whose number is the same as the number of questions whose answer is a?

(a) b; (b) c; (c)d; (d) e; (e) none of the above

7. According to the alphabetical order, how many letters are there between the answer to this question and the answer to the next question?

(a) 4; (b) 3; (c) 2; (d) 1; (e) 0. (Note: there is one letter between a and b)

8. The number of questions whose answers are vowel is:

(a) 2; (b) 3; (c) 4; (d) 5; (e) 6. (Note: a and e are vowels)

9. The number of questions whose answers are consonants is:

(a) a prime number; (b) a factorial; (c) a square number; (d) a cubic number; (e)  multiple of 5

10. The answer to this question is:

(a) a; (b) b; (c) c; (d) d; (e) e

l  Tip

General steps: Record the options a, b, c, d, and e for the question respectively as 1, 2, 3, 4, and 5, for convenience of counting for every answer. Firstly set all answer options for the questions to 0, and then add, in turn, 1 to each option, and evaluate each option according to the task description of. If an answer option is incorrect for a certain question, then add 1 to it till the correct one is found. If there is still no correct answer after 5 options have all went through a round of examination, then return to reset the answer to the preceding question. Skip the question whose answer is 0 directly and make no evaluation.

1.  Initialize answers to the 10 questions as 0, and set the serial number of the current question to 1.

2.  Loop from the first question. Firstly add 1 to each answer option to the question, judge whether the answer to the current question is 6. If it is 6, the answer falls out of the five options. Then set the answer to the question as 0, and subtract 1 from i to return to the preceding question to restart the loop.

3.  Then invoke the sub-function to judge the answer options for the question. If they are not correct, then proceed to the next loop.

4.  If the correct answer is found, add 1 to i and judge whether i is equal to 11. If it is equal to 11, 10 questions have been answered. Next convert the final answers into a string for storage, and set i as i-1 to return to the preceding question to continue the loop to see whether there is any other answer that satisfies the condition. End the loop when i is equal to 1.

5.  The sub-function judges the options question by question. The judgment process is this: first look at whether this question or the relevant question is 0; if it is 0which indicates no answer is set, skip over the judgment; if it is not 0, then make judgment according to the question.

l  Code