The pair project is designed to optimize the functionality of individual projects.
Since neither of us realized the generation of random formulas, we only achieved the problem by reading the documents, and we have perfected this aspect in this week.
The following is a function that generates a calculation:
void Create () {srand (unsigned) time (NULL)); int len;int operate;int op0,op1,op2;int Exibrac,brac1,brac2;char Op;do{len = rand ()% 11;} while (len<=2); Exibrac = rand ()% 2;//0 does not exist, 1 exists in parentheses BRAC1 = rand ()% (len-1); FILE *FP = fopen ("Test.txt", "w+"); operate = LEN-1;OP1 = rand ()% 100;OP0 = rand ()% 2;if (Len-operate==brac1 && Exi BRAC = = 1) {op = ' ('; fprintf (FP, "%c", op); brac2 = BRAC1 + 1 + rand ()% (len-brac1-1);} if (op0==0) {fprintf (FP, "%d", OP1);} else{fprintf (FP, "%d", OP1); op= ' | '; fprintf (FP, "%c", op); OP1 = 2 + rand ()% 98;fprintf (FP, "%d", OP1); }while (operate>0) {Op2=rand ()% 4;switch (OP2) {Case 0:op = ' + '; break;case 1:op = '-'; break;case 2:op = ' * '; Break;case 3:o p = '/'; break;} operate--;fprintf (FP, "%c", op); if (len-operate==brac1 && Exibrac = = 1) {op = ' ('; fprintf (FP, '%c ', op); brac2 = BRAC1 + 1 + rand ()% (len-brac1- 1);} 1+ (2+3+4op1 = rand ()% 100;OP0 = rand ()% 2;if (op0==0) {fprintf (FP, "%d", OP1);} else{fprintf (FP, "%d", OP1); op= ' | '; fprintf (FP, "%c", op); OP1 = 2 + rand ()% 98;fprintf (FP, "%d", OP1); }if (LEN-OPERATE==BRAC2) {op = ') '; fprintf (FP, "%c", op); }}fclose (FP);}
Knot Pair Project Progress