Project requirements: The program randomly generates arithmetic calculation questions, and after the user fills out the answer to determine the correct answer.
Pair member: Li Qiao
Task assignment: The algorithm thought and the main function adopted by Li Qiao are responsible for.
I am responsible for some code input and results testing.
Roughly divided into two modules: 1. Randomly generated arithmetic calculation questions 2. Determine the correct and correct input answers
The main code is as follows:
1#include <stdio.h>2#include <string.h>3#include <time.h>4#include <stdlib.h>5 intMain ()6 {7 Charstr[]="+-*/";8Srand (Time (0));9 intres[Ten];Ten for(inti =0; i<=9; i++) One { A intA = rand ()% -+1; - intb = rand ()% -+1; - intc = rand ()%4; the if(c==3) - { - while(a%b) A = rand ()% -+1, B = rand ()% -+1; - } +printf"%d%c%d\n", a,str[c],b); - if(c==0) Res[i] = a +b; + Else if(c==1) Res[i] = A-b; A Else if(c==2) Res[i] = A *b; at ElseRes[i] = A/b; - } - ints[Ten]; -printf"Please enter an answer separated by a space \ n"); - for(intI=0; i<=9; i++) - { inscanf"%d",&s[i]); - } to for(intI=0; i<=9; i++) + { - if(s[i]!=Res[i]) the { *printf"question%d is wrong, the correct answer is%d\n", i+1, Res[i]); $ }Panax Notoginseng } - return 0; the}
The results of the operation are as follows:
First-week pairing programming arithmetic