Experimental contents and requirements:
[experimental content]
1. Through this experiment, the computer logic problem-solving ability is initially cultivated. Familiar with the application of assignment statement and if statement; Master the use of switch multi-branch statements and if nested statements
2. Apply basic programming knowledge such as data types, operators and expressions to specific programming.
3. Further master the use of input and output functions scanf, printf and getchar, and be familiar with the use of common mathematical functions in math.h
4. Master the application method of circular sentences.
5. Understand the random number generation function.
[experimental requirements]
Complete the experiment independently within the specified time.
1, submit the experimental report (electronic version)
2. Submit the corresponding source file (file name EX6_x name. C, such as EX6_ 1 Peng Jian. c)。
3, requirements from simple to complex, the latter requirements are modified on the basis of the previous, the first six questions, each question needs to keep its own program, the last six questions, each question is modified on the basis of the previous question, the last program can be kept (if you do the ninth question, you can keep the name of EX6_9. C, and if you do 1 1, you can keep EX6 _ 65438.
Second, the experimental principle and design scheme:
1, selection of function header, while loop statement, switch(case) statement, conditional expression, if else conditional statement, self-increasing operator, setting complex variables, and outputting random operands.
2. Variables should include fractional variables and rank variables, select the number of algorithm questions and the variables that are correct in calculation, randomly output the variables of two operands and the variables that input the results according to the operation symbols, and finally judge whether to proceed or not. The intermediate results are the switch of the selection operator () and the switch of the fractional grade (), the self-increasing of the wrong question to the question and the self-increasing of the calculation of the selection operator.
3. Analysis method of the problem: firstly, consider setting plastic variables and character variables, and consider continuous loop calculation, and choose the while statement for loop. In the loop body, complete the previous output prompt operator, optional operator, answer and output random operands. Then the switch statement is used to judge the selected operator, and the variable is used for self-increasing operation, thus calculating the number of wrong questions and the selected operation symbol. At the end of the loop body, if else statement is used to judge whether to continue execution or jump out of the loop. Finally, the score is calculated according to the result of self-increasing calculation and formula, and the score is made by switch statement.
Third, the source code
# include & ltstdio.h & gt
# include & ltstdlib.h & gt
# include & lttime.h & gt
void main()
{
..........
}
Fourth, the test results and enlightenment
Because you want to continue the loop by entering y, you choose to use the while statement. In the while statement, we should combine the previous calculation according to the prompt, nest the switch statement, use the conditional expression to calculate whether the result is correct and what the question type is. Finally, judge the score with switch statement.
V. Experimental experience:
Describe the difficulties and problems encountered in programming or program compilation and their solutions.