修复中位数错误问题
This commit is contained in:
1 parent
8e357ccd5a
commit
eccf255f02
2 files changed
+9
-3
No files matched your search
@@ -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');
|
||||
// 判断考试状态
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in new issue
Block a user