From eccf255f020bcf0b77730d2f7590a768a93a5ac3 Mon Sep 17 00:00:00 2001 From: win10 Date: Mon, 12 Oct 2020 10:40:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=AD=E4=BD=8D=E6=95=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chengji/controller/Bjtongji.php | 6 ++++++ app/chengji/model/Tongji.php | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/chengji/controller/Bjtongji.php b/app/chengji/controller/Bjtongji.php index 790ffaf4..50309871 100644 --- a/app/chengji/controller/Bjtongji.php +++ b/app/chengji/controller/Bjtongji.php @@ -292,6 +292,12 @@ class Bjtongji extends AdminBase // 统计各班级成绩 public function tongji() { + $tj = new \app\chengji\model\Tongji; + $arr = [1,7,3,4,5,6,2,8]; + $zw = $tj->zhongweishu($arr); + + halt('zw=' . $zw); + // 获取变量 $kaoshi_id = input('post.kaoshi_id'); // 判断考试状态 diff --git a/app/chengji/model/Tongji.php b/app/chengji/model/Tongji.php index a1d6c18e..52430861 100644 --- a/app/chengji/model/Tongji.php +++ b/app/chengji/model/Tongji.php @@ -246,15 +246,15 @@ class Tongji extends BaseModel $zws = 0; $cnt = count($arr); - if ($cnt = 1) { + if ($cnt === 1) { $zws = $arr[0]; }elseif ($cnt > 1) { $mod = $cnt % 2; if ($mod == 0) { $i = $cnt / 2; - $zws = ($arr[$i] + $arr[$i + 1]) / 2; + $zws = ($arr[$i - 1] + $arr[$i]) / 2; }else{ - $i = ($cnt + 1) / 2; + $i = ($cnt - 1) / 2; $zws = $arr[$i]; } }else{