From 87814705668ae833c16696b3b53fa1f0d3daffea Mon Sep 17 00:00:00 2001 From: zhuyanshuo <3663541984@qq.com> Date: Mon, 16 Mar 2026 14:48:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'w2'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- w2 | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 w2 diff --git a/w2 b/w2 deleted file mode 100644 index 6f67c4a..0000000 --- a/w2 +++ /dev/null @@ -1,33 +0,0 @@ -public class DataCleaner { - public static void main(String[] args) { - int[] sensorData = {85, -5, 92, 0, 105, 999, 88, 76}; - - int validSum = 0; // 有效数据总和 - int validCount = 0; // 有效数据个数 - - // 遍历传感器数据 - for (int value : sensorData) { - if (value == 999) { - System.out.println("致命错误:传感器掉线,终止处理。"); - break; - } - - if (value <= 0 || value > 100) { - System.out.println("警告:发现越界数据 [" + value + "],已跳过"); - continue; - } - - // 正常范围数据:1 到 100 之间 - validSum += value; - validCount++; - } - - // 输出平均值或无有效数据提示 - if (validCount > 0) { - double average = (double) validSum / validCount; - System.out.println("有效数据平均值:" + average); - } else { - System.out.println("无有效数据"); - } - } -} \ No newline at end of file