We solved the basic function and basic setting parameters according to the homework given by teacher Feng:
1) Number of topics (requirements for individual projects)
2) range of values (requirements for individual projects)
3) Maximum number of operators in the topic
4) Whether there is a multiplication method in the question
5) There are no negative numbers in the topic
We have two teams to complete this assignment, our team is mainly responsible for the following functions:
1) public void Build_nomul_nodiv_nominus function
2) public void Build_mul_div_minus function
3) private string Getstr2 function
1. Main Page
2. Overall design
3. Function code
1) public void Build_nomul_nodiv_nominus function
public void Build_nomul_nodiv_nominus (int cal) {if (cal = = 1) {int[] num1; Int[] num2; int I, R1, R2; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); int s = r1 + R2; if ((R1>r2&&s > 0) && (r1!=0&&r2!=0)) {Num1[i] = R1 ; Num2[i] = R2; } else {i--; Continue }} for (i = 0; i < n; i++) {if (Num1[i]! = 0&& ; num2[i]!=0{LISTVIEW1.ITEMS.ADD ("+num1[i]+") "+ Getstr1 (1) +" ("+ num2[i]+") "+" = "); }}} if (cal = = 2) {int[] num1; Int[] num2; Int[] num3; int I, R1, R2,R3; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; num3 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R3 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); int s = r1 + r2 + R3; if (r1> (R2+R3) && (r2*r3>0) &&s > 0) && (r1! = 0&&r2! = 0&&r3! = 0)) {Num1[i] = r1; Num2[i] = r2; num3[i] = R3; } else {i--; Continue }} for (i = 0; i < n; i++) {if (num1[i]! = 0 &&am P Num2[i] = 0&&num3[i]! = 0) {listView1.Items.Add ("(" + num1[i] + ")" + GETSTR1 (1) + "(" + num2[i] + ")" + Getstr1 (1) + "(" + num3[i] + ")" + "="); }}} if (cal = = 3) {int[] num1; Int[] num2; Int[] num3; Int[] NUM4; int I, R1, R2, R3,R4; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; num3 = new INT[100];NUM4 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R3 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R4 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); int S1 = r1 + R2; int s2 = r3 + r4; if (R1>r2&&s1 > 0&&r3>r4&&s2>0) && (r1! = 0&& R2! = 0 &&r3!= 0 &&r4!=0)) {num1[i] = r1; Num2[i] = r2; num3[i] = r3; Num4[i] = R4; } else {i--; Continue }} for (i = 0; i < n; i++) {if (NUM1 [i]! = 0 && num2[i]! = 0 && num3[i]! = 0&&num4[i]!=0) ListView1.Items.Add ("(" + num1[ I] + ")" + Getstr1 (1) + "(" + num2[i] + ")" + Getstr1 (1) + "(" + num3[i] + ")" + Getstr1 (1) + "(" + num4[i] + "+" = "); }} if (cal = = 4) {int[] num1; Int[] num2; Int[] num3; Int[] NUM4; Int[] NUM5; int I, R1, R2, R3, R4,R5; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; num3 = new INT[100]; NUM4 = new INT[100]; NUM5 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R3 = r.next (int. ParSE (textf.text), Int. Parse (Textt.text)); R4 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R5 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); int S=R1+R2+R3+R4+R5; int S1 = r1 + R2; int s2 = r3 + r4; if (r1>r2&&r3>r4&&s1>0&&s2>0&&s1> (S2+R5) &&s>0& &s2*r5>0) && (r1! = 0&&r2! = 0&&R3! = 0&&R4! = 0&&r5! = 0)) {Num1[i] = r1; Num2[i] = r2; num3[i] = r3; Num4[i] = R4; Num5[i] = R5; } else {i--; Continue }} for (i = 0; i < n; i++) {if (num1[i]! = 0 &&am P Num2[i]! = 0 && num3[i]! = 0 && num4[i]! = 0&& num5[i]!=0) ListView1.Items.Add ("(" + num1[i] + ")" + Getstr1 (1) + "(" + num2[i] + ")" + Getstr1 (1) + "(" + num3[i] + ")" + Getstr1 (1) + "(" + num4[i] + ")" + Getstr1 (1) + "(" + num5[i] + ")" + "="; }} if (cal = = 5) {int[] num1; Int[] num2; Int[] num3; Int[] NUM4; Int[] NUM5; Int[] NUM6; int I, R1, R2, R3, R4, R5,R6; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; num3 = new INT[100]; NUM4 = new INT[100]; NUM5 = new INT[100]; NUM6 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. PArse (Textt.text)); R3 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R4 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R5 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R6 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); int s = r1 + r2 + r3 + R4 + R5 + R6; int S1 = r1 + R2; int s2 = r3 + r4; int s3 = R5 + R6; if ((r1>r2&&s1>0&&r3>r4&&s2>0&&r5>r6&&s3>0) && (R1! = 0&&R2 = 0&&R3! = 0&&R4! = 0&&R5! 0&& r6! = 0)) {Num1[i] = r1; Num2[i] = r2; num3[i] = r3; Num4[i] = R4; Num5[i] = R5; Num6[i] = R6; } else {i--; Continue }} for (i = 0; i < n; i++) {ListView1.Items.Add ("(" + Num1[i] + ")" + Getstr1 (1) + "(" + num2[i] + ")" + Getstr1 (1) + "(" + num3[i "+") "+ Getstr1 (1) +" ("+ num4[i] +") "+ GETSTR1 (1) + "(" + num5[i] + ")" + Getstr1 (1) + "(" + num6[i] + ")" + "="); } } }
2) public void Build_mul_div_minus function
public void Build_mul_div_minus (int cal) {if (cal = = 1) {int[] num1; Int[] num2; int I, R1, R2; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); int s = r1 + R2; if (r1! = 0 && r2! = 0) {Num1[i] = r1; Num2[i] = R2; } else {i--; Continue }} for (i = 0; i < n; i++) {if (num1[i]! = 0 &&am P Num2[i]! = 0) {ListView1.Items.Add ("(" + num1[i] + ")" + GETSTR2 (1) + "(" + num2[i] + ")" + "="); }}} if (cal = = 2) {int[] num1; Int[] num2; Int[] num3; int I, R1, R2, R3; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; num3 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R3 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); if (r1! = 0 && r2! = 0 && R3! = 0) {Num1[i] = r1; Num2[i] = R2; Num3[i] = R3; } else {i--; Continue }} for (i = 0; i < n; i++) {if (num1[i]! = 0 &&am P Num2[i]! = 0 && num3[i]! = 0) {listView1.Items.Add ("(" + num1[i] + ")" + GETSTR2 (1) + "(" + num2[i] + ")" + GETSTR2 (1) + "(" + num3[i] + ")" + "="); }}} if (cal = = 3) {int[] num1; Int[] num2; Int[] num3; Int[] NUM4; int I, R1, R2, R3, R4; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; num3 = new INT[100]; NUM4 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). PArse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R3 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R4 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); if (r1! = 0 && r2! = 0 && R3! = 0 && R4! = 0) {Num1[i] = R1; Num2[i] = R2; Num3[i] = R3; Num4[i] = R4; } else {i--; Continue }} for (i = 0; i < n; i++) {if (num1[i]! = 0 &&am P Num2[i]! = 0 && num3[i]! = 0 && num4[i]! = 0) ListView1.Items.Add ("(" + num1[i] + " ) "+ GETSTR2 (1) +" ("+ num2[i] +") "+ GETSTR2 (1) +" ("+ num3[i] +") "+ GETSTR2 (1) +" ("+ num4[i] +") "+" = "; } } if (cal = = 4) {int[] num1; Int[] num2; Int[] num3; Int[] NUM4; Int[] NUM5; int I, R1, R2, R3, R4, R5; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; num3 = new INT[100]; NUM4 = new INT[100]; NUM5 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R3 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R4 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R5 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); if (r1! = 0 && r2! = 0 && R3! = 0 && R4! = 0 && R5! = 0) {Num1[i] = r1; Num2[i] = R2; num3[i ] = R3; Num4[i] = R4; Num5[i] = R5; } else {i--; Continue }} for (i = 0; i < n; i++) {if (num1[i]! = 0 &&am P Num2[i]! = 0 && num3[i]! = 0 && num4[i]! = 0 && num5[i]! = 0) Listview1.ite Ms. Add ("(" + num1[i] + ")" + GETSTR2 (1) + "(" + num2[i] + ")" + GETSTR2 (1) + "(" + num3[i] + ")" + GETSTR2 (1) + "(" + num4[i ") + ")" + GETSTR2 (1) + "(" + num5[i] + ")" + "="); }} if (cal = = 5) {int[] num1; Int[] num2; Int[] num3; Int[] NUM4; Int[] NUM5; Int[] NUM6; int I, R1, R2, R3, R4, R5, R6; int n = Int. Parse (Textsum.text); Random r = new Random (); NUM1 = new INT[100]; num2 = new INT[100]; num3 = new INT[100]; NUM4 = new INT[100]; NUM5 = new INT[100]; NUM6 = new INT[100]; for (i = 0; i < n; i++) {r1 = r.next (int). Parse (textf.text), Int. Parse (Textt.text)); r2 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R3 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R4 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R5 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); R6 = r.next (int. Parse (textf.text), Int. Parse (Textt.text)); if (r1! = 0 && r2! = 0 && R3! = 0 && R4! = 0 && R5 = 0 && r6! 0) { Num1[i] = R1; Num2[i] = R2; Num3[i] = R3; Num4[i] = R4; Num5[i] = R5; Num6[i] = R6; } else {i--; Continue }} for (i = 0; i < n; i++) {ListView1.Items.Add ("(" + Num1[i] + ")" + GETSTR2 (1) + "(" + num2[i] + ")" + GETSTR2 (1) + "(" + num3[i "+") "+ GETSTR2 (1) +" ("+ num4[i] +") "+ GETSTR2 (1) + "(" + num5[i] + ")" + GETSTR2 (1) + "(" + num6[i] + ")" + "="); } } }
3) private string Getstr2 function
private string Getstr2 (int num) { string result = ""; for (int i = 0; i < num; i++) { int r = R10. Next (strs2. Length); Result + = Strs2[r]; } return result; }
4. Personal Impressions
This assignment for me is very difficult for my foundation too poor a lot of code can not understand, if not Li Hongliang classmates help me Maybe I can not finish this homework.
I'm going to study C language, I can't even read the code.
Pair program Programming-arithmetic