1293: 实验2-1-1 心率序列统计与多结果返回 / Heart Rate Statistics and Multiple Results

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:160 Solved:86

Description

【中文题面】
输入一组心率数据。请编写函数分析这组数据,并通过指针参数一次返回多个统计结果。
要求定义并调用函数:void analyzeHeartRate(const int hr[], int n, int* maxValue, int* minValue, double* average, int* abnormalCount)。
其中 maxValue 表示最大心率,minValue 表示最小心率,average 表示平均心率,abnormalCount 表示相邻两次心率差的绝对值大于等于 20 的次数。
[English Statement]
Given a sequence of heart-rate values, write a function to analyze the data and return several results through pointer parameters.
You should define and call: void analyzeHeartRate(const int hr[], int n, int* maxValue, int* minValue, double* average, int* abnormalCount).
maxValue is the maximum heart rate, minValue is the minimum heart rate, average is the average value, and abnormalCount is the number of adjacent pairs whose absolute difference is at least 20.
No smoothing is required. The focus is array traversal, functions, and returning multiple non-array results through pointers.

Input

【输入】
第一行输入整数 n。
第二行输入 n 个整数,表示心率序列。
数据保证 1 <= n <= 100,心率为整数。
[Input]
The first line contains n.
The second line contains n integers.
It is guaranteed that 1 <= n <= 100.

Output

【输出】
第一行输出最大值、最小值和平均值,平均值保留 1 位小数。
第二行输出异常变化次数。
[Output]
Print the maximum value, the minimum value, and the average rounded to 1 decimal place on the first line.
Print the abnormal-change count on the second line.

Sample Input Copy

6
72 75 98 101 80 79

Sample Output Copy

101 72 84.2
2

HINT

【拓展练习与 AI 使用建议】
拓展练习:把固定阈值 20 改为从输入读取阈值 T;或额外用一个指针参数返回大于 100 的心率个数。
向 AI 提问时,明确要求只使用数组、循环、if、函数和指针参数,不使用 vector、string、类、模板、递归或复杂库函数。
拿到 AI 代码后,请先找出 maxValue、minValue、average、abnormalCount 分别在哪里被赋值,再改阈值或增加一个返回结果。
[Extension and AI Advice]
Extension: read the threshold T from input instead of using 20, or add one pointer parameter to return the count of values greater than 100.
When prompting AI, ask for arrays, loops, if statements, functions, and pointer parameters only. Avoid vector, string, classes, templates, recursion, or over-designed helpers.
After receiving code, identify where each returned result is assigned before changing the threshold or adding a new returned value.