Main function: This program can generate arithmetic automatically, there is the choice of algorithms and the ability to view the answer.
Design ideas: You can choose the algorithm, you can randomly appear calculation questions, can appear the answer, you can also directly into the next question.
Source:
#include <stdio.h>#include<stdlib.h>#include<time.h>Main () {inta,b,op,os;aq1:printf ("Choose the algorithm you want to challenge \ n");p rintf ("1. Addition 2. Subtraction 3. Multiplication 4. Division \ n"); scanf ("%d",&op);Switch(OP) {aq: Case 1: Srand ((unsigned) time (NULL)); a=rand ()% -+1; B=rand ()% -+1;p rintf ("The topic is:%d +%d =? \ n", A, b);p rintf ("1. Review the answer 2. Do the next question \ n"); scanf ("%d",&OS);if(os==1) {printf ("%d +%d =%d\n\n\n", a,b,a+b);Gotoaq1;}ElseGotoaq; Break; at: Case 2: A=rand ()% -+1; B=rand ()% -+1;p rintf ("The topic is:%d-%d =? \ n", A, b);p rintf ("1. Review the answer 2. Do the next question \ n"); scanf ("%d",&OS);if(os==1) {printf ("%d-%d =%d\n\n\n", a,b,a-b);Gotoaq1;}ElseGotoat ; Break; AQ2: Case 3: A=rand ()% -+1; B=rand ()% -+1;p rintf ("The topic is:%d *%d =? \ n", A, b);p rintf ("1. Review the answer 2. Do the next question \ n"); scanf ("%d",&OS);if(os==1) {printf ("%d *%d =%d\n\n\n", a,b,a*b);Gotoaq1;}ElseGotoaq2;aq3: Case 4: A=rand ()% -+1; B=rand ()% -+1;p rintf ("The topic is:%d/%d =? \ n", A, b);p rintf ("1. Review the answer 2. Do the next question \ n"); scanf ("%d",&OS);if(os==1) {printf ("%d/%d =%d\n\n\n", a,b,a/b);Gotoaq1;}ElseGotoaq3; Break;}}
Run:
Summary: This time to do is still very immature, do when there are a lot of errors, referring to the same type of online program, only to find the wrong place, in the reference to the online program, the idea is gradually opened, after the finished look at their own procedures, there is a sense of accomplishment, very rewarding, I believe in the next study, I will reap more.
Job two: Automatically generate arithmetic