Heim > Backend-Entwicklung > PHP-Tutorial > 软件工程结对作业02 软件工程的发展 软件工程的概念 软件工程的定义

软件工程结对作业02 软件工程的发展 软件工程的概念 软件工程的定义

WBOY
Freigeben: 2016-07-29 08:54:09
Original
1263 Leute haben es durchsucht

1.设计思想:

  本次任务我用php实现的主要功能,默认必须有加减法。

  首先,创建index.php文件,在HTML语句里创建表单,表单内容包括,出题数目,最大最小值,及其他的一些选项。

  然后,创建rubric.php文件,将表单信息提交到此文件下,四则运算方法实现时调用传递过来的值。实现四则运算的方法和前几次用Java时的方法差不多,将代码做了修改和优化。将题目和答案分别放入question.txtanswer.txt文件里,以备后用。

  第三,创建submitAnswer.phpacceptAnswer.phpdeleteAnswer.phpjudgeAnswer.php文件,分别用于在线提交答案,接收答案,删除答案和判断答案。提交的答案放在answer1.txt文件里,判断答案时通过比较answer.txtanswer1.txt文件里的内容即可。

2.源程序代码

软件工程专业,软件工程论文,软件工程硕士,软件工程培训,软件工程导论,软件工程考研,软件工程试题,软件工程排名,软件工程课程,软件工程吧,软件工程答案,软件工程ppt,软件工程的发展,软件工程的概念,软件工程的定义软件工程专业,软件工程论文,软件工程硕士,软件工程培训,软件工程导论,软件工程考研,软件工程试题,软件工程排名,软件工程课程,软件工程吧,软件工程答案,软件工程ppt,软件工程的发展,软件工程的概念,软件工程的定义

<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 operation
</span><span>  8</span> -->
<span>  9</span> 
<span> 10</span>     
<span> 11</span>         <meta charset="UTF-8">
<span> 12</span>         <title>四则运算出题系统</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('最小值输入不合法'<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('最大值输入不合法'<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('出题数目输入不合法'<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">登录</button>   <button type="button">注册</button>
<span> 40</span>         <br><br> 
<span> 41</span>         <center>
<span> 42</span>         <font color="red" size="7" face="楷体">欢迎来到小学四则运算出题系统</font> <br><br><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">默认只有两个数参与运算的加减法</font> <br><br>
<span> 46</span><span> 47</span>         <font color="blue" size="4">请输入参与运算的最小数值(非负整数)</font>
<span> 48</span>         <input type="text" name="min"> <br><br>
<span> 49</span><span> 50</span>         <font color="blue" size="4">请输入参与运算的最大数值(非负整数且不小于最小数值)</font>
<span> 51</span>         <input type="text" name="max"> <br><br>
<span> 52</span><span> 53</span>         <font color="blue" size="4">请输入出题数目(正整数)</font>
<span> 54</span>         <input type="text" name="num"> <br><br>
<span> 55</span><span> 56</span>         <font color="blue" size="4">选择参与运算的数的个数</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><!--num1中的1位1 2 3的1,不是l m n的l-->
<span> 60</span><span> 61</span>         <font color="blue" size="4">选择是否加入乘法</font>
<span> 62</span>         <input type="radio" value="t" name="mul"><span>是
</span><span> 63</span>         <input type="radio" value="f" name="mul" checked>否 <br><br>
<span> 64</span><span> 65</span>         <font color="blue" size="4">选择是否加入除法</font>
<span> 66</span>         <input type="radio" value="t" name="div"><span>是
</span><span> 67</span>         <input type="radio" value="f" name="div" checked>否 <br><br>
<span> 68</span><span> 69</span>         <input type="submit" value="确认" name="send">
<span> 70</span>         <input type="reset" value="重置" 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>出题界面</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>最大值</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>最小值</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>出题数目</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>参与运算的个数</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>选择是否加入乘法 是t否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>选择是否加入除法 是t否f</span><span>109</span><span>            }
</span><span>110</span><span>111</span><span>/*</span><span> 定义数组 </span><span>*/</span><span>112</span><span>$a</span>=<span>array</span>();  <span>//</span><span>方法中使用,存储随机数字和运算符</span><span>113</span><span>$amd</span>=<span>array</span>(); <span>//</span><span>方法中使用,将算好乘/除法后的算式存入此数组</span><span>114</span><span>$b</span>=<span>array</span>();  <span>//</span><span>调用方法时使用</span><span>115</span><span>$d</span>=<span>array</span>();  <span>//</span><span>存储题目</span><span>116</span><span>$e</span>=<span>array</span>();  <span>//</span><span>存储答案</span><span>117</span><span>118</span><span>/*</span><span> Result 类用于封装结果 </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存储计算结果</span><span>122</span><span>            }
</span><span>123</span><span>124</span><span>/*</span><span> 运算符只有加减的方法 </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> 运算符为加减乘的方法 </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> 将算式中的数和运算符存入数组$a </span><span>*/</span><span>154</span><span>/*</span><span>如果此循环中在运算符左右两侧加入空格,则在后面while循环中的if条件语句中的运算符也应加空格,否则会出错</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) 为算式中参与运算的数和运算符个数之和</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> 将算式中的乘法算完后的算式存入数组$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>//</span><span>运算符左右是否有空格应和上面的for循环保持一致</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> 算出算式的答案$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>//</span><span>运算符左右是否有空格应和上面的for循环保持一致</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> 将数组中的值连接为字符串算式$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> 运算符为加减除的方法 </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> 将算式中的数和运算符存入数组$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> 将算式中的除法算完后的算式存入数组$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>避免除法有余数</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> 算出算式的答案$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> 将算式放入字符串$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> 运算符为加减乘除的方法 </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> 将算式中的数和运算符存入数组$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> 将算式中的除法算完后的算式存入数组$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>避免除法有余数</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> 算出算式的答案$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> 将算式放入字符串$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> 两个数的加减法 </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>当结果为负时,重新随机</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>避免重复</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>结果为负,重新出题</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> 两个数的加减乘法 </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>当结果为负时,重新随机</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>避免重复</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>结果为负,重新出题</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> 两个数的加减除法 </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>当结果为负时,重新随机</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>避免重复</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>结果为负,重新出题</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> 两个数的加减乘除法 </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>结果为负,重新出题</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>判断重复</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>结果为负,重新出题</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> 三个数的加减法 </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>结果为负,重新出题</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>判断重复</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>结果为负,重新出题</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> 三个数的加减乘法 </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>结果为负,重新出题</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>判断重复</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>结果为负,重新出题</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> 三个数的加减除法 </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>结果为负,重新出题</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>判断重复</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>结果为负,重新出题</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> 三个数的加减乘除法 </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>结果为负,重新出题</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>判断重复</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>结果为负,重新出题</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> 四个数的加减法 </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>结果为负,重新出题</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>判断重复</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>结果为负,重新出题</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> 四个数的加减乘法 </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>结果为负,重新出题</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>判断重复</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>结果为负,重新出题</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> 四个数的加减除法 </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>结果为负,重新出题</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>判断重复</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>结果为负,重新出题</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>
Nach dem Login kopieren
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage