Code review
My small partner is Yu Yue, she uses the C language, C-free to write the arithmetic, the following is her code
#include <stdio.h>#include<stdlib.h>#include<time.h>Main () {intA,b,op,os; printf ("[arithmetic to challenge]\n"); 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;}}
Every line of code has been checked, there is no problem, there is no unnecessary code, and the entire program can be run out. But she and I came up with the same problem, all without comment. and code writing is not standardized, there is no indentation, such as see If,else statements, because are left-aligned, it is not easy to find, and then combine the above content, it is not clear, which caused the code overall readability is not high, not easy to maintain.
20160317 second question