Home >Backend Development >PHP Tutorial >Software Engineering Pairing Work 02 The Development of Software Engineering The Concept of Software Engineering The Definition of Software Engineering

Software Engineering Pairing Work 02 The Development of Software Engineering The Concept of Software Engineering The Definition of Software Engineering

WBOY
WBOYOriginal
2016-07-29 08:54:091264browse

1. Design idea:

 The main functions I implemented in this task using php must have addition and subtraction by default.

First, create the index.php file and create a form in the HTML statement. The form content includes the number of questions, the maximum and minimum values, and some other options.

  Then, create the rubric.php file, submit the form information to this file, and call the passed values ​​when implementing the four arithmetic operations methods. The method of implementing the four arithmetic operations is similar to the method used when using Java several times before. The code has been modified and optimized. Put the questions and answers into the question.txt and answer.txt files respectively for future use.

Third, create submitAnswer.php, acceptAnswer.php, deleteAnswer.php and judgeAnswer.php files for submitting answers online, receiving answers, and deleting them respectively. Answers and Determine Answers. The submitted answers are placed in the answer1.txt file. When judging the answer, just compare the contents in the answer.txt and answer1.txt files.

2. Source code

Software Engineering Pairing Work 02 The Development of Software Engineering The Concept of Software Engineering The Definition of Software EngineeringSoftware Engineering Pairing Work 02 The Development of Software Engineering The Concept of Software Engineering The Definition of Software Engineering

<span> 1</span> index.<span>php
</span><span> 2</span> 
<span> 3</span> <!--
<span> 4</span> start <span>date</span> 2016/3/28
<span> 5</span> completion <span>date</span> 2016/4/7
<span> 6</span><span>author Jing
</span><span> 7</span><span>this program is about four arithmetic operations
</span><span> 8</span> -->
<span> 9</span> 
<span> 10</span> 
<span> 11</span> <meta charset="UTF-8">
<span> 12</span> <title>Four arithmetic calculation system</title>
<span> 13</span> <script>
<span> 14<span>function<span> check() {
<span> 15<span>var tt=/^(0|[1-9]d*)$/<span>;
<span> 16<span>if(!tt.test(form1.<span>min.<span>value))
<span> 17<span> {
<span> 18 alert('The minimum value input is illegal'<span>);
<span> 19 form1.<span>min.<span>focus();
<span> 20<span>return<span>false<span>;
<span> 21<span> }
<span> 22<span>if(!tt.test(form1.<span>max.value) || (form1.<span>max.value<form1.<span>min.<span>value))
<span> 23<span> {
<span> 24 alert('The maximum value input is illegal'<span>);
<span> 25 form1.<span>min.<span>focus();
<span> 26<span>return<span>false<span>;
<span> 27<span> }
<span> 28<span>if(!tt.test(form1.num.value) || (form1.num.value==0<span>))
<span> 29<span> {
<span> 30 alert('The number of questions entered is illegal'<span>);
<span> 31 form1.num.<span>focus();
<span> 32<span>return<span>false<span>;
<span> 33<span> }
<span> 34<span>return<span>true<span>;
<span> 35<span> }<span> 36 </script>
<span> 37</span> 
<span> 38</span> 
<span> 39</span> <button type="button">Login</button>   <button type="button">Register</button>
<span> 40</span> <br><br>
<span> 41</span> <center>
<span> 42</span> <font color="red" size="7" face="毷体">Welcome to the primary school four arithmetic operation question system</font> <br><br>&lt ;br/>
<span> 43</span><span> 44</span> <form action="rubric.php" target="_blank" method="post" name="form1">
<span> 45</span> <font color="red" size="5">By default, only two numbers participate in addition and subtraction</font> <br><br>
<span> 46</span><span> 47</span> <font color="blue" size="4">Please enter the minimum value (non-negative integer) involved in the operation</font>
<span> 48</span> <input type="text" name="min"> <br><br>
<span> 49</span><span> 50</span> <font color="blue" size="4">Please enter the maximum value to participate in the operation (non-negative integer and not less than the minimum value)</font>
<span> 51</span> <input type="text" name="max"> <br><br>
<span> 52</span><span> 53</span> <font color="blue" size="4">Please enter the number of questions (positive integer)</font>
<span> 54</span> <input type="text" name="num"> <br><br>
<span> 55</span><span> 56</span> <font color="blue" size="4">Select the number of numbers to participate in the operation</font>
<span> 57</span> <input type="radio" value="2" name="num1" checked>2
<span> 58</span> <input type="radio" value="3" name="num1">3
<span> 59</span> <input type="radio" value="4" name="num1">4 <br><br><!--1 digit in num1 1 2 3 1, not l m n's l-->
<span> 60</span><span> 61</span> <font color="blue" size="4">Choose whether to add multiplication</font>
<span> 62</span> <input type="radio" value="t" name="mul"><span>Yes
</span><span> 63</span> <input type="radio" value="f" name="mul" checked>No <br><br>
<span> 64</span><span> 65</span> <font color="blue" size="4">Choose whether to add division</font>
<span> 66</span> <input type="radio" value="t" name="div"><span>Yes
</span><span> 67</span> <input type="radio" value="f" name="div" checked>No <br><br>
<span> 68</span><span> 69</span> <input type="submit" value="Confirm" name="send">
<span> 70</span> <input type="reset" value="Reset" name="send">
<span> 71</span> </form>
<span> 72</span> </center>
<span> 73</span> 
<span> 74</span> 
<span> 75</span><span> 76</span> rubric.<span>php
</span><span> 77</span><span> 78</span> 
<span> 79</span> 
<span> 80</span> <meta charset="UTF-8">
<span> 81</span> <title>Question setting interface</title>
<span> 82</span> 
<span> 83</span> 
<span> 84</span><span> 85</span> <span>php
</span><span> 86</span><span>if</span>(<span>is_numeric</span>(<span>$_POST</span>["max"<span>]))
</span><span> 87</span><span> {
</span><span> 88</span><span>$max</span>=<span>$_POST</span>["max"]; <span>//</span><span>maximum value</span><span> 89</span><span> }
</span><span> 90</span><span>if</span>(<span>is_numeric</span>(<span>$_POST</span>["min"<span>]))
</span><span> 91</span><span> {
</span><span> 92</span><span>$min</span>=<span>$_POST</span>["min"]; <span>//</span><span>minimum value</span><span> 93</span><span> }
</span><span> 94</span><span>if</span>(<span>is_numeric</span>(<span>$_POST</span>["num"<span>]))
</span><span> 95</span><span> {
</span><span> 96</span><span>$num</span>=<span>$_POST</span>["num"]; <span>//</span><span>Number of questions</span><span> 97</span><span> }
</span><span> 98</span><span>if</span>(<span>is_numeric</span>(<span>$_POST</span>["num1"<span>]))
</span><span> 99</span><span> {
</span><span>100</span><span>$num1</span>=<span>$_POST</span>["num1"]; <span>//</span><span>Number of items participating in the operation</span><span>101</span><span> }</span><span>102</span><span>if</span>(<span>is_string</span>(<span>$_POST</span>["mul"<span>]))
</span><span>103</span><span> {
</span><span>104</span><span>$mul</span>=<span>$_POST</span>["mul"]; <span>//</span><span>Choose whether to add multiplication Yes t No f</span><span>105</span><span> }
</span><span>106</span><span>if</span>(<span>is_string</span>(<span>$_POST</span>["div"<span>]))
</span><span>107</span><span> {
</span><span>108</span><span>$div</span>=<span>$_POST</span>["div"]; <span>//</span><span>Choose whether to add division Yes or no f</span><span>109</span><span> }
</span><span>110</span><span>111</span><span>/*</span><span> Define array </span><span>*/</span><span>112</span><span>$a</span>=<span>array</span>(); <span>//</span><span> used in the method to store random numbers and operators</span> <span> 113</span><span>$amd</span>=<span>array</span>(); Used in the <span>//</span><span> method to store the multiplication/division calculations into this array</span><span>114</span><span>$b</span>=<span>array</span>(); <span>//</span><span>Use </span><span>115</span><span>$d</span>=<span>array</span>(); <span>//</span><span>to store questions</span><span>116</span><span>$e</span>=<span>array</span>(); <span>// </span> <span>Storing answers</span><span>117</span><span>118</span><span>/*</span><span> The Result class is used to encapsulate the results</span><span>*/</span><span>119</span><span>class</span><span> Result
</span><span>120</span><span> {
</span><span>121</span><span>public</span><span>$r1</span>; <span>//</span><span>$r1 stores calculation results</span><span>122</span><span> }
</span><span>123</span><span>124</span><span>/*</span><span> The operator only has addition and subtraction methods</span><span>*/</span><span>125</span><span>function</span> addSub(<span>$min</span>,<span>$max</span>,<span>$num1</span>, <span>$result </span><span>)
</span><span>126</span><span> {
</span><span>127</span><span>$str</span>=<span>mt_rand</span>(<span>$min</span>,<span>$max</span><span>);
</span><span>128</span><span>$re</span>=<span>$str</span><span>;
</span><span>129</span><span>for</span>(<span>$i</span>=1;<span>$i</span>$num1;<span>$i</span>++<span>)
</span><span>130</span><span> {
</span><span>131</span><span>$a</span>[<span>$i</span>]= <span>mt_rand</span>(<span>$min</span>,<span>$max</span><span>);
</span><span>132</span><span>$c</span>=<span>mt_rand</span>(0,1<span>);
</span><span>133</span><span>if</span>(<span>$c</span>==0<span>)
</span><span>134</span><span> {
</span><span>135</span><span>$str</span>=<span>$str</span>." + ".<span>$a</span>[<span>$i</span><span>];
</span><span>136</span><span>$re</span>=<span>$re</span>+<span>$a</span>[<span>$i</span><span>];
</span><span>137</span><span> }
</span><span>138</span><span>if</span>(<span>$c</span>==1<span>)
</span><span>139</span><span> {
</span><span>140</span><span>$str</span>=<span>$str</span>." - ".<span>$a</span>[<span>$i</span><span>];
</span><span>141</span><span>$re</span>=<span>$re</span>-<span>$a</span>[<span>$i</span><span>];
</span><span>142</span><span> }
</span><span>143</span><span> }
</span><span>144</span><span>$result</span>->r1=<span>$re</span><span>;
</span><span>145</span><span>$str</span>=<span>$str</span>." = "<span>;
</span><span>146</span><span>return</span><span>$str</span><span>;
</span><span>147</span><span> }
</span><span>148</span><span>149</span><span>/*</span><span> The operator is the method of addition, subtraction and multiplication</span><span>*/</span><span>150</span><span>function</span> addSubMul(<span>$min</span>,<span>$max</span>,<span>$num1</span> ,<span>$ result</span><span>)
</span><span>151</span><span> {
</span><span>152</span><span>$a</span>[0]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>153</span><span>/*</span><span> Store the numbers and operators in the calculation into array $a </span><span>*/</span><span>154</span><span>/*</span><span>If spaces are added to the left and right sides of the operator in this loop, then in The operator in the if conditional statement in the subsequent while loop should also add spaces, otherwise an error will occur</span><span>*/</span><span>155</span><span>for</span>(<span>$i</span>=1;<span>$i</span>$ num1-1);<span>$i</span>=<span>$i</span>+2) <span>//</span><span>(2*$num1-1) is the sum of the number of numbers and operators involved in the calculation </span><span>156</span><span> {
</span><span>157</span><span>$c</span>= <span>mt_rand</span>(0, 2<span>);
</span><span>158</span><span>if</span>(<span>$c</span>==0<span>)
</span><span>159</span><span> {
</span><span>160</span><span>$a</span>[<span>$i</span>]=' + '<span>;
</span><span>161</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>162</span><span> }</span><span>163</span><span>if</span>(<span>$c</span>==1<span>)
</span><span>164</span><span> {
</span><span>165</span><span>$a</span>[<span>$i</span>]=' - '<span>;
</span><span>166</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>167</span><span> }
</span><span>168</span><span>if</span>(<span>$c</span>==2<span>)
</span><span>169</span><span> {
</span><span>170</span><span>$a</span>[<span>$i</span>]=' x '<span>;
</span><span>171</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>172</span><span> }
</span><span>173</span><span> }
</span><span>174</span><span>/*</span><span> Store the multiplication formula in the array $amd </span><span>*/</span><span>175</span><span>$i</span>=0<span>;
</span><span>176</span><span>$j</span>=0<span>;
</span><span>177</span><span>while</span>(<span>$i</span>$num1-1)) <span>//Whether there are spaces around the operator should be consistent with the for loop above</span><span>178</span><span> {
</span><span>179</span><span>if</span>(<span>$a</span>[<span>$i</span>]==' x '<span>)
</span><span>180</span><span> {
</span><span>181</span><span>$amd</span>[<span>$j</span>-1]=<span>$amd</span>[<span>$j</span>-1]*<span>$a</span>[<span>$i</span>+1<span>];
</span><span>182</span><span>$i</span>=<span>$i</span>+2<span>;
</span><span>183</span><span> }
</span><span>184</span><span>else</span><span>185</span><span> {
</span><span>186</span><span>$amd</span>[<span>$j</span>]=<span>$a</span>[<span>$i</span><span>];
</span><span>187</span><span>$j</span>++<span>;
</span><span>188</span><span>$i</span>++<span>;
</span><span>189</span><span> }
</span><span>190</span><span> }
</span><span>191</span><span>/*</span><span> Calculate the answer to the equation $re </span><span>*/</span><span>192</span><span>$re</span>=<span>$amd</span>[0<span>];
</span><span>193</span><span>$k</span>=1<span>;
</span><span>194</span><span>while</span>(<span>$k</span>$j) <span>//Whether there are spaces around the operator should be consistent with the for loop above</span><span>195</span><span> {
</span><span>196</span><span>if</span>(<span>$amd</span>[<span>$k</span>]==' + '<span>)
</span><span>197</span><span> {
</span><span>198</span><span>$re</span>=<span>$re</span>+<span>$amd</span>[<span>$k</span>+1<span>];
</span><span>199</span><span>$k</span>=<span>$k</span>+2<span>;
</span><span>200</span><span>continue</span><span>;
</span><span>201</span><span> }
</span><span>202</span><span>if</span>(<span>$amd</span>[<span>$k</span>]==' - '<span>)
</span><span>203</span><span> {
</span><span>204</span><span>$re</span>=<span>$re</span>-<span>$amd</span>[<span>$k</span>+1<span>];
</span><span>205</span><span>$k</span>=<span>$k</span>+2<span>;
</span><span>206</span><span> }
</span><span>207</span><span> }
</span><span>208</span><span>/*</span><span> Concatenate the values ​​in the array into a string calculation $str </span><span>*/</span><span>209</span><span>$str</span>=<span>$a</span>[0<span>];
</span><span>210</span><span>for</span>(<span>$i</span>=1;<span>$i</span>$num1-1);<span>$i</span>++<span>)
</span><span>211</span><span> {
</span><span>212</span><span>$str</span>.=<span>$a</span>[<span>$i</span><span>];
</span><span>213</span><span> }
</span><span>214</span><span>$result</span>->r1=<span>$re</span><span>;
</span><span>215</span><span>$str</span>=<span>$str</span>." = "<span>;
</span><span>216</span><span>return</span><span>$str</span><span>;
</span><span>217</span><span> }</span><span>218</span><span>219</span><span>/*</span><span> The operators are addition and subtraction methods</span><span>*/</span><span>220</span><span>function</span> addSubDiv(<span>$min</span>,<span>$max</span>,<span>$num1</span> ,<span>$ result</span><span>)
</span><span>221</span><span> {
</span><span>222</span><span>$a</span>[0]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>223</span><span>/*</span><span> Store the numbers and operators in the calculation into array $a </span><span>*/</span><span>224</span><span>for</span>(<span>$i</span>=1;<span>$i</span>$num1-1);<span>$i</span>=<span>$i</span>+2<span>)
</span><span>225</span><span> {
</span><span>226</span><span>$c</span>= <span>mt_rand</span>(0, 2<span>);
</span><span>227</span><span>if</span>(<span>$c</span>==0<span>)
</span><span>228</span><span> {
</span><span>229</span><span>$a</span>[<span>$i</span>]=' + '<span>;
</span><span>230</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>231</span><span> }
</span><span>232</span><span>if</span>(<span>$c</span>==1<span>)
</span><span>233</span><span> {
</span><span>234</span><span>$a</span>[<span>$i</span>]=' - '<span>;
</span><span>235</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>236</span><span> }
</span><span>237</span><span>if</span>(<span>$c</span>==2<span>)
</span><span>238</span><span> {
</span><span>239</span><span>$a</span>[<span>$i</span>]=' ÷ '<span>;
</span><span>240</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>241</span><span> }
</span><span>242</span><span> }
</span><span>243</span><span>/*</span><span> Store the calculated division formula in the array $amd </span><span>*/</span><span>244</span><span>$i</span>=0<span>;
</span><span>245</span><span>$j</span>=0<span>;
</span><span>246</span><span>while</span>(<span>$i</span>$num1-1<span>))
</span><span>247</span><span> {
</span><span>248</span><span>if</span>(<span>$a</span>[<span>$i</span>]==' ÷ '<span>)
</span><span>249</span><span> {
</span><span>250</span><span>while</span>((<span>$amd</span>[<span>$j</span>-1] % <span>$a</span>[<span>$i</span>+1]!=0) || <span>$a</span>[<span>$i</span>+ 1]==0 ) <span>//</span><span>Avoid division with remainder</span><span>251</span><span> {
</span><span>252</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>,<span>$max</span><span>);
</span><span>253</span><span> }
</span><span>254</span><span>$amd</span>[<span>$j</span>-1]=<span>$amd</span>[<span>$j</span>-1]/<span>$a</span>[<span>$i</span>+1<span>];
</span><span>255</span><span>$i</span>=<span>$i</span>+2<span>;
</span><span>256</span><span> }
</span><span>257</span><span>else</span><span>258</span><span> {
</span><span>259</span><span>$amd</span>[<span>$j</span>]=<span>$a</span>[<span>$i</span><span>];
</span><span>260</span><span>$j</span>++<span>;
</span><span>261</span><span>$i</span>++<span>;
</span><span>262</span><span> }
</span><span>263</span><span> }
</span><span>264</span><span>/*</span><span> Calculate the answer to the equation $re </span><span>*/</span><span>265</span><span>$re</span>=<span>$amd</span>[0<span>];
</span><span>266</span><span>$k</span>=1<span>;
</span><span>267</span><span>while</span>(<span>$k</span>$j<span>)
</span><span>268</span><span> {
</span><span>269</span><span>if</span>(<span>$amd</span>[<span>$k</span>]==' + '<span>)
</span><span>270</span><span> {
</span><span>271</span><span>$re</span>=<span>$re</span>+<span>$amd</span>[<span>$k</span>+1<span>];
</span><span>272</span><span>$k</span>=<span>$k</span>+2<span>;
</span><span>273</span><span>continue</span><span>;
</span><span>274</span><span> }
</span><span>275</span><span>if</span>(<span>$amd</span>[<span>$k</span>]==' - '<span>)
</span><span>276</span><span> {
</span><span>277</span><span>$re</span>=<span>$re</span>-<span>$amd</span>[<span>$k</span>+1<span>];
</span><span>278</span><span>$k</span>=<span>$k</span>+2<span>;
</span><span>279</span><span> }
</span><span>280</span><span> }</span><span>281</span><span>282</span><span>/*</span><span> Put the calculation into the string $str </span><span>*/</span><span>283</span><span>$str</span>=<span>$a</span>[0<span>];
</span><span>284</span><span>for</span>(<span>$i</span>=1;<span>$i</span>$num1-1);<span>$i</span>++<span>)
</span><span>285</span><span> {
</span><span>286</span><span>$str</span>.=<span>$a</span>[<span>$i</span><span>];
</span><span>287</span><span> }
</span><span>288</span><span>$result</span>->r1=<span>$re</span><span>;
</span><span>289</span><span>$str</span>=<span>$str</span>." = "<span>;
</span><span>290</span><span>return</span><span>$str</span><span>;
</span><span>291</span><span> }
</span><span>292</span><span>293</span><span>/*</span><span> The operators are addition, subtraction, multiplication and division methods</span><span>*/</span><span>294</span><span>function</span> addSubMulDiv(<span>$min</span>,<span>$max</span>,<span>$num1 </span>,<span>$ result</span><span>)
</span><span>295</span><span> {
</span><span>296</span><span>$a</span>[0]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>297</span><span>/*</span><span> Store the numbers and operators in the calculation into array $a </span><span>*/</span><span>298</span><span>for</span>(<span>$i</span>=1;<span>$i</span>$num1-1);<span>$i</span>=<span>$i</span>+2<span>)
</span><span>299</span><span> {
</span><span>300</span><span>$c</span>= <span>mt_rand</span>(0, 3<span>);
</span><span>301</span><span>if</span>(<span>$c</span>==0<span>)
</span><span>302</span><span> {
</span><span>303</span><span>$a</span>[<span>$i</span>]=' + '<span>;
</span><span>304</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>305</span><span> }
</span><span>306</span><span>if</span>(<span>$c</span>==1<span>)
</span><span>307</span><span> {
</span><span>308</span><span>$a</span>[<span>$i</span>]=' - '<span>;
</span><span>309</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>310</span><span> }
</span><span>311</span><span>if</span>(<span>$c</span>==2<span>)
</span><span>312</span><span> {
</span><span>313</span><span>$a</span>[<span>$i</span>]=' x '<span>;
</span><span>314</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>315</span><span> }
</span><span>316</span><span>if</span>(<span>$c</span>==3<span>)
</span><span>317</span><span> {
</span><span>318</span><span>$a</span>[<span>$i</span>]=' ÷ '<span>;
</span><span>319</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>, <span>$max</span><span>);
</span><span>320</span><span> }
</span><span>321</span><span> }
</span><span>322</span><span>/*</span><span> Store the calculated division formula in the array $amd </span><span>*/</span><span>323</span><span>$i</span>=0<span>;
</span><span>324</span><span>$j</span>=0<span>;
</span><span>325</span><span>while</span>(<span>$i</span>$num1-1<span>))
</span><span>326</span><span> {
</span><span>327</span><span>if</span>(<span>$a</span>[<span>$i</span>]==' x '<span>)
</span><span>328</span><span> {
</span><span>329</span><span>$amd</span>[<span>$j</span>-1]=<span>$amd</span>[<span>$j</span>-1]*<span>$a</span>[<span>$i</span>+1<span>];
</span><span>330</span><span>$i</span>=<span>$i</span>+2<span>;
</span><span>331</span><span> }
</span><span>332</span><span>else</span><span>if</span>(<span>$a</span>[<span>$i</span>]==' ÷ '<span>)
</span><span>333</span><span> {
</span><span>334</span><span>while</span>((<span>$amd</span>[<span>$j</span>-1] % <span>$a</span>[<span>$i</span>+1]!=0) || <span>$a</span>[<span>$i</span>+ 1]==0 ) <span>//</span><span>Avoid division with remainder</span><span>335</span><span> {
</span><span>336</span><span>$a</span>[<span>$i</span>+1]= <span>mt_rand</span>(<span>$min</span>,<span>$max</span><span>);
</span><span>337</span><span> }
</span><span>338</span><span>$amd</span>[<span>$j</span>-1]=<span>$amd</span>[<span>$j</span>-1]/<span>$a</span>[<span>$i</span>+1<span>];
</span><span>339</span><span>$i</span>=<span>$i</span>+2<span>;
</span><span>340</span><span> }
</span><span>341</span><span>else</span><span>342</span><span> {
</span><span>343</span><span>$amd</span>[<span>$j</span>]=<span>$a</span>[<span>$i</span><span>];
</span><span>344</span><span>$j</span>++<span>;
</span><span>345</span><span>$i</span>++<span>;
</span><span>346</span><span> }
</span><span>347</span><span> }</span><span>348</span><span>/*</span><span> Calculate the answer to the equation $re </span><span>*/</span><span>349</span><span>$re</span>=<span>$amd</span>[0<span>];
</span><span>350</span><span>$k</span>=1<span>;
</span><span>351</span><span>while</span>(<span>$k</span>$j<span>)
</span><span>352</span><span> {
</span><span>353</span><span>if</span>(<span>$amd</span>[<span>$k</span>]==' + '<span>)
</span><span>354</span><span> {
</span><span>355</span><span>$re</span>=<span>$re</span>+<span>$amd</span>[<span>$k</span>+1<span>];
</span><span>356</span><span>$k</span>=<span>$k</span>+2<span>;
</span><span>357</span><span>continue</span><span>;
</span><span>358</span><span> }
</span><span>359</span><span>if</span>(<span>$amd</span>[<span>$k</span>]==' - '<span>)
</span><span>360</span><span> {
</span><span>361</span><span>$re</span>=<span>$re</span>-<span>$amd</span>[<span>$k</span>+1<span>];
</span><span>362</span><span>$k</span>=<span>$k</span>+2<span>;
</span><span>363</span><span> }
</span><span>364</span><span> }
</span><span>365</span><span>/*</span><span> Put the calculation into the string $str </span><span>*/</span><span>366</span><span>$str</span>=<span>$a</span>[0<span>];
</span><span>367</span><span>for</span>(<span>$i</span>=1;<span>$i</span>$num1-1);<span>$i</span>++<span>)
</span><span>368</span><span> {
</span><span>369</span><span>$str</span>.=<span>$a</span>[<span>$i</span><span>];
</span><span>370</span><span> }
</span><span>371</span><span>$result</span>->r1=<span>$re</span><span>;
</span><span>372</span><span>$str</span>=<span>$str</span>." = "<span>;
</span><span>373</span><span>return</span><span>$str</span><span>;
</span><span>374</span><span> }
</span><span>375</span><span>376</span><span>$r</span>= <span>new</span><span> Result();
</span><span>377</span><span>378</span><span>/*</span><span> Addition and subtraction of two numbers</span><span>*/</span><span>379</span><span>if</span>((<span>$num1</span>==2) && (<span>$mul</span>=='f ') && (<span>$div</span>=='f'<span>))
</span><span>380</span><span> {
</span><span>381</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>382</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>383</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>384</span><span> {
</span><span>385</span><span>$j</span>=0<span>;
</span><span>386</span><span>$bool</span>=<span>true</span><span>;
</span><span>387</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>388</span><span>while</span>((<span>$r</span>->r1)//<span>When the result is negative, re-random </span><span>389</span><span> {
</span><span>390</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>391</span><span> }
</span><span>392</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Avoid duplication</span><span>393</span><span> {
</span><span>394</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>395</span><span> {
</span><span>396</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>397</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>398</span><span> {
</span><span>399</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>400</span><span> }
</span><span>401</span><span>$j</span>=0<span>;
</span><span>402</span><span> }
</span><span>403</span><span>$j</span>++<span>;
</span><span>404</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>405</span><span> {
</span><span>406</span><span>$bool</span>=<span>false</span><span>;
</span><span>407</span><span> }
</span><span>408</span><span> }</span><span>409</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>410</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>411</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>412</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>413</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>414</span><span> }
</span><span>415</span><span>fclose</span>(<span>$question</span><span>);
</span><span>416</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>417</span><span> }
</span><span>418</span><span>419</span><span>/*</span><span> Addition, subtraction and multiplication of two numbers</span><span>*/</span><span>420</span><span>if</span>((<span>$num1</span>==2) && (<span>$mul</span>=='t ') && (<span>$div</span>=='f'<span>))
</span><span>421</span><span> {
</span><span>422</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>423</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>424</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>425</span><span> {
</span><span>426</span><span>$j</span>=0<span>;
</span><span>427</span><span>$bool</span>=<span>true</span><span>;
</span><span>428</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>429</span><span>while</span>((<span>$r</span>->r1)//<span>When the result is negative, re-random </span><span>430</span><span> {
</span><span>431</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>432</span><span> }
</span><span>433</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Avoid duplication</span><span>434</span><span> {
</span><span>435</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>436</span><span> {
</span><span>437</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>438</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>439</span><span> {
</span><span>440</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>441</span><span> }
</span><span>442</span><span>$j</span>=0<span>;
</span><span>443</span><span> }
</span><span>444</span><span>$j</span>++<span>;
</span><span>445</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>446</span><span> {
</span><span>447</span><span>$bool</span>=<span>false</span><span>;
</span><span>448</span><span> }
</span><span>449</span><span> }
</span><span>450</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>451</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>452</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>453</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>454</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>455</span><span> }
</span><span>456</span><span>fclose</span>(<span>$question</span><span>);
</span><span>457</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>458</span><span> }</span><span>459</span><span>460</span><span>/*</span><span> Addition and subtraction of two numbers</span><span>*/</span><span>461</span><span>if</span>((<span>$num1</span>==2) && (<span>$mul</span>=='f ') && (<span>$div</span>=='t'<span>))
</span><span>462</span><span> {
</span><span>463</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>464</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>465</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>466</span><span> {
</span><span>467</span><span>$j</span>=0<span>;
</span><span>468</span><span>$bool</span>=<span>true</span><span>;
</span><span>469</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>470</span><span>while</span>((<span>$r</span>->r1)//<span>When the result is negative, re-random </span><span>471</span><span> {
</span><span>472</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>473</span><span> }
</span><span>474</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Avoid duplication</span><span>475</span><span> {
</span><span>476</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>477</span><span> {
</span><span>478</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>479</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>480</span><span> {
</span><span>481</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>482</span><span> }
</span><span>483</span><span>$j</span>=0<span>;
</span><span>484</span><span> }
</span><span>485</span><span>$j</span>++<span>;
</span><span>486</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>487</span><span> {
</span><span>488</span><span>$bool</span>=<span>false</span><span>;
</span><span>489</span><span> }
</span><span>490</span><span> }
</span><span>491</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>492</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>493</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>494</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>495</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>496</span><span> }
</span><span>497</span><span>fclose</span>(<span>$question</span><span>);
</span><span>498</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>499</span><span> }
</span><span>500</span><span>501</span><span>/*</span><span> Addition, subtraction, multiplication and division of two numbers</span><span>*/</span><span>502</span><span>if</span>((<span>$num1</span>==2) && (<span>$mul</span>==' t') && (<span>$div</span>=='t'<span>))
</span><span>503</span><span> {
</span><span>504</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>505</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>506</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>507</span><span> {
</span><span>508</span><span>$j</span>=0<span>;
</span><span>509</span><span>$bool</span>=<span>true</span><span>;
</span><span>510</span><span>$b</span>[<span>$i</span>]= addSubMulDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>511</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>512</span><span> {
</span><span>513</span><span>$b</span>[<span>$i</span>]= addSubMulDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>514</span><span> }</span><span>515</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Judge duplicate</span><span>516</span><span> {
</span><span>517</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>518</span><span> {
</span><span>519</span><span>$b</span>[<span>$i</span>]= addSubMulDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>520</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>521</span><span> {
</span><span>522</span><span>$b</span>[<span>$i</span>]= addSubMulDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>523</span><span> }
</span><span>524</span><span>$j</span>=0<span>;
</span><span>525</span><span> }
</span><span>526</span><span>$j</span>++<span>;
</span><span>527</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>528</span><span> {
</span><span>529</span><span>$bool</span>=<span>false</span><span>;
</span><span>530</span><span> }
</span><span>531</span><span> }
</span><span>532</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>533</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>534</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>535</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>536</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>537</span><span> }
</span><span>538</span><span>fclose</span>(<span>$question</span><span>);
</span><span>539</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>540</span><span> }
</span><span>541</span><span>542</span><span>/*</span><span> Addition and subtraction of three numbers</span><span>*/</span><span>543</span><span>if</span>((<span>$num1</span>==3) && (<span>$mul</span>=='f ') && (<span>$div</span>=='f'<span>))
</span><span>544</span><span> {
</span><span>545</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>546</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>547</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>548</span><span> {
</span><span>549</span><span>$j</span>=0<span>;
</span><span>550</span><span>$bool</span>=<span>true</span><span>;
</span><span>551</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>552</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>553</span><span> {
</span><span>554</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>555</span><span> }
</span><span>556</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Judge duplicate</span><span>557</span><span> {
</span><span>558</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>559</span><span> {
</span><span>560</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>561</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>562</span><span> {
</span><span>563</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>564</span><span> }
</span><span>565</span><span>$j</span>=0<span>;
</span><span>566</span><span> }
</span><span>567</span><span>$j</span>++<span>;
</span><span>568</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>569</span><span> {
</span><span>570</span><span>$bool</span>=<span>false</span><span>;
</span><span>571</span><span> }
</span><span>572</span><span> }</span><span>573</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>574</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>575</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>576</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>577</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>578</span><span> }
</span><span>579</span><span>fclose</span>(<span>$question</span><span>);
</span><span>580</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>581</span><span> }
</span><span>582</span><span>583</span><span>/*</span><span> Addition, subtraction and multiplication of three numbers</span><span>*/</span><span>584</span><span>if</span>((<span>$num1</span>==3) && (<span>$mul</span>=='t ') && (<span>$div</span>=='f'<span>))
</span><span>585</span><span> {
</span><span>586</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>587</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>588</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>589</span><span> {
</span><span>590</span><span>$j</span>=0<span>;
</span><span>591</span><span>$bool</span>=<span>true</span><span>;
</span><span>592</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>593</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>594</span><span> {
</span><span>595</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>596</span><span> }
</span><span>597</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Judge duplicate</span><span>598</span><span> {
</span><span>599</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>600</span><span> {
</span><span>601</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>602</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>603</span><span> {
</span><span>604</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>605</span><span> }
</span><span>606</span><span>$j</span>=0<span>;
</span><span>607</span><span> }
</span><span>608</span><span>$j</span>++<span>;
</span><span>609</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>610</span><span> {
</span><span>611</span><span>$bool</span>=<span>false</span><span>;
</span><span>612</span><span> }
</span><span>613</span><span> }
</span><span>614</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>615</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>616</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>617</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>618</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>619</span><span> }
</span><span>620</span><span>fclose</span>(<span>$question</span><span>);
</span><span>621</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>622</span><span> }</span><span>623</span><span>624</span><span>/*</span><span> Addition, subtraction and division of three numbers</span><span>*/</span><span>625</span><span>if</span>((<span>$num1</span>==3) && (<span>$mul</span>=='f ') && (<span>$div</span>=='t'<span>))
</span><span>626</span><span> {
</span><span>627</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>628</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>629</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>630</span><span> {
</span><span>631</span><span>$j</span>=0<span>;
</span><span>632</span><span>$bool</span>=<span>true</span><span>;
</span><span>633</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>634</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>635</span><span> {
</span><span>636</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>637</span><span> }
</span><span>638</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Judge duplicate</span><span>639</span><span> {
</span><span>640</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>641</span><span> {
</span><span>642</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>643</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>644</span><span> {
</span><span>645</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>646</span><span> }
</span><span>647</span><span>$j</span>=0<span>;
</span><span>648</span><span> }
</span><span>649</span><span>$j</span>++<span>;
</span><span>650</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>651</span><span> {
</span><span>652</span><span>$bool</span>=<span>false</span><span>;
</span><span>653</span><span> }
</span><span>654</span><span> }
</span><span>655</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>656</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>657</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>658</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>659</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>660</span><span> }
</span><span>661</span><span>fclose</span>(<span>$question</span><span>);
</span><span>662</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>663</span><span> }
</span><span>664</span><span>665</span><span>/*</span><span> Addition, subtraction, multiplication and division of three numbers</span><span>*/</span><span>666</span><span>if</span>((<span>$num1</span>==3) && (<span>$mul</span>==' t') && (<span>$div</span>=='t'<span>))
</span><span>667</span><span> {
</span><span>668</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>669</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>670</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>671</span><span> {
</span><span>672</span><span>$j</span>=0<span>;
</span><span>673</span><span>$bool</span>=<span>true</span><span>;
</span><span>674</span><span>$b</span>[<span>$i</span>]= addSubMulDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>675</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>676</span><span> {
</span><span>677</span><span>$b</span>[<span>$i</span>]= addSubMulDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>678</span><span> }</span><span>679</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Judge duplicate</span><span>680</span><span> {
</span><span>681</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>682</span><span> {
</span><span>683</span><span>$b</span>[<span>$i</span>]= addSubMulDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>684</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>685</span><span> {
</span><span>686</span><span>$b</span>[<span>$i</span>]= addSubMulDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>687</span><span> }
</span><span>688</span><span>$j</span>=0<span>;
</span><span>689</span><span> }
</span><span>690</span><span>$j</span>++<span>;
</span><span>691</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>692</span><span> {
</span><span>693</span><span>$bool</span>=<span>false</span><span>;
</span><span>694</span><span> }
</span><span>695</span><span> }
</span><span>696</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>697</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>698</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>699</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>700</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>701</span><span> }
</span><span>702</span><span>fclose</span>(<span>$question</span><span>);
</span><span>703</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>704</span><span> }
</span><span>705</span><span>706</span><span>/*</span><span> Addition and subtraction of four numbers</span><span>*/</span><span>707</span><span>if</span>((<span>$num1</span>==4) && (<span>$mul</span>=='f ') && (<span>$div</span>=='f'<span>))
</span><span>708</span><span> {
</span><span>709</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>710</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>711</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>712</span><span> {
</span><span>713</span><span>$j</span>=0<span>;
</span><span>714</span><span>$bool</span>=<span>true</span><span>;
</span><span>715</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>716</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>717</span><span> {
</span><span>718</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>719</span><span> }
</span><span>720</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Judge duplicate</span><span>721</span><span> {
</span><span>722</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>723</span><span> {
</span><span>724</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>725</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>726</span><span> {
</span><span>727</span><span>$b</span>[<span>$i</span>]= addSub(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>728</span><span> }
</span><span>729</span><span>$j</span>=0<span>;
</span><span>730</span><span> }
</span><span>731</span><span>$j</span>++<span>;
</span><span>732</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>733</span><span> {
</span><span>734</span><span>$bool</span>=<span>false</span><span>;
</span><span>735</span><span> }
</span><span>736</span><span> }</span><span>737</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>738</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>739</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>740</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>741</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>742</span><span> }
</span><span>743</span><span>fclose</span>(<span>$question</span><span>);
</span><span>744</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>745</span><span> }
</span><span>746</span><span>747</span><span>/*</span><span> Addition, subtraction and multiplication of four numbers</span><span>*/</span><span>748</span><span>if</span>((<span>$num1</span>==4) && (<span>$mul</span>=='t ') && (<span>$div</span>=='f'<span>))
</span><span>749</span><span> {
</span><span>750</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>751</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>752</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>753</span><span> {
</span><span>754</span><span>$j</span>=0<span>;
</span><span>755</span><span>$bool</span>=<span>true</span><span>;
</span><span>756</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>757</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>758</span><span> {
</span><span>759</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>760</span><span> }
</span><span>761</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Judge duplicate</span><span>762</span><span> {
</span><span>763</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>764</span><span> {
</span><span>765</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>766</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>767</span><span> {
</span><span>768</span><span>$b</span>[<span>$i</span>]= addSubMul(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>769</span><span> }
</span><span>770</span><span>$j</span>=0<span>;
</span><span>771</span><span> }
</span><span>772</span><span>$j</span>++<span>;
</span><span>773</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>774</span><span> {
</span><span>775</span><span>$bool</span>=<span>false</span><span>;
</span><span>776</span><span> }
</span><span>777</span><span> }
</span><span>778</span><span>echo</span> "( ".(<span>$i</span>+1)." )  ".<span>$b</span>[<span>$i</span>]."<br><br>"<span>;
</span><span>779</span><span>$d</span>[<span>$i</span>]=<span>$b</span>[<span>$i</span>]."n"<span>;
</span><span>780</span><span>$e</span>[<span>$i</span>]=<span>$r</span>->r1."n"<span>;
</span><span>781</span><span>fwrite</span>(<span>$question</span>,<span>$d</span>[<span>$i</span><span>]);
</span><span>782</span><span>fwrite</span>(<span>$answer</span>,<span>$e</span>[<span>$i</span><span>]);
</span><span>783</span><span> }
</span><span>784</span><span>fclose</span>(<span>$question</span><span>);
</span><span>785</span><span>fclose</span>(<span>$answer</span><span>);
</span><span>786</span><span> }</span><span>787</span><span>788</span><span>/*</span><span> Addition, subtraction and division of four numbers</span><span>*/</span><span>789</span><span>if</span>((<span>$num1</span>==4) && (<span>$mul</span>=='f ') && (<span>$div</span>=='t'<span>))
</span><span>790</span><span> {
</span><span>791</span><span>$question</span> = <span>fopen</span>("question.txt", "w"<span>);
</span><span>792</span><span>$answer</span>= <span>fopen</span>("answer.txt", "w"<span>);
</span><span>793</span><span>for</span>(<span>$i</span>=0;<span>$i</span>$num;<span>$i</span>++<span>)
</span><span>794</span><span> {
</span><span>795</span><span>$j</span>=0<span>;
</span><span>796</span><span>$bool</span>=<span>true</span><span>;
</span><span>797</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>798</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>799</span><span> {
</span><span>800</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>801</span><span> }
</span><span>802</span><span>while</span>((<span>$bool</span>) && (<span>$i</span>!=0))<span>//</span><span>Judge duplicate</span><span>803</span><span> {
</span><span>804</span><span>while</span>(<span>$b</span>[<span>$i</span>]==<span>$b</span>[<span>$j</span><span>])
</span><span>805</span><span> {
</span><span>806</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>807</span><span>while</span>((<span>$r</span>->r1)//<span>The result is negative, re-question </span><span>808</span><span> {
</span><span>809</span><span>$b</span>[<span>$i</span>]= addSubDiv(<span>$min</span>, <span>$max</span>, <span>$num1</span>, <span>$r</span><span>);
</span><span>810</span><span> }
</span><span>811</span><span>$j</span>=0<span>;
</span><span>812</span><span> }
</span><span>813</span><span>$j</span>++<span>;
</span><span>814</span><span>if</span>(<span>$j</span>==<span>$i</span><span>)
</span><span>815</span><span> {
</span><span>816</span><span>$bool</span>=<span>false</span><span>;
</span><span>817</span><span></span>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn