
如果你的英语不怎么好,学习步骤:
- 先根据中文的内容学习,把知识掌握。
- 然后再用英语学习一遍,遇到的生词标记出来,注音释义。
- 复习一遍。
以下是题目的翻译:
垃圾清理小组的成员每月完成一次垃圾清理工作。成员姓名存储在一维数组 PickerName[] 中。
每位成员所捡垃圾的重量(以千克为单位,保留一位小数,例如 8.4)存储在另一个一维数组 PickedWeight[] 中。
两个数组中同一索引位置的数据对应同一成员。例如,索引 10 处的 PickerName[] 和 PickedWeight[] 数据属于同一成员。
每月会颁发一个小奖品给捡拾重量最重的两名成员。同时,所有捡拾重量超过三公斤的成员将获得证书。
编写一个程序,满足以下要求:
- 允许输入并验证成员捡拾的重量
- 按重量降序对数组 PickedWeight[] 和 PickerName[] 进行排序
- 输出捡拾重量最重的两名成员的姓名和重量,并分别标记为“小组最佳”和“小组第二佳”
- 将所有符合证书资格的成员姓名存入数组 PickerCertificate[]
- 输出一条消息,说明需要打印的证书数量。
需使用伪代码或程序代码实现,并添加注释说明代码逻辑。
无需声明数组或变量,假设已预先定义。
所有输入和输出需包含清晰的提示信息。
无需初始化数组 PickerName[] 中的数据。
题目逐行分析:
Members of a litter picking group complete a litter pick every month. Members’ names are stored in one-dimensional (1D) array PickerName[]
成员姓名存储在 1D 数组中 PickerName[] ,说明这个数组存储的都是姓名,也就是字符串类型的字段。
Declaring arrays (8.2.1)
模版:
DECLARE <identifier> : ARRAY[<l>:<u>] OF <data type>
实例
DECLARE PickerName : ARRAY[1:200] OF STRING
Each member stores the weight of the litter they have picked in another one-dimensional (1D) array PickedWeight[].The weights are in kilograms with one decimal place, for example 8.4
每个成员拾取的垃圾的重量存储在PickedWeight[],重量是带有小数的,因此数据类型是Real
仿照上面的,声明这个数组
DECLARE PickedWeight:ARRAY[1:200] OF REAL
以下是这两个数组的样例,接下来的编程就是操作这两个数组的数据

The position of each member’s data in the two arrays is the same. For example, the member stored at index 10 in PickerName[] and at index 10 in PickedWeight[] is the same.
Every month, there is a small prize awarded to the members of the group who have the two heaviest weights. Certificates are awarded to all members with a pick weight of over three
kilograms.
这几句话是说明,
一是说这个数组存储的数据的位置是对应的,如上面的例子所示 Alice 拾取的垃圾的重量为 5.2 kg。
二是说每个月都会给前两名办法奖励,给所有超过3公斤的会员颁发证书。此处引申出来下面将需要数组的冒泡排序(bubble sort),和线性搜索(linear search)的需要
Write a program that meets the following requirements:
• allows the weight of members’ picks to be input and validated
• sorts the arrays PickedWeight[] and PickerName[] in descending order of weight
• outputs the member names and the pick weights of the members with the two heaviest picksand identifies them as “Best in Group” and “Second best in Group”
• stores the names of all the members who will receive a certificate in the array PickerCertificate[]
• outputs a message stating the number of certificates to be printed.
以上是题目的核心要求
- 允许录入捡拾垃圾的重量,操作PickedWeight[]数组,使用For…Loop 录入每一个重量,使用Repeat …Utill 检验每一次录入:重量必须>0,小于某一个重量,题目没说,需要自行补充。
- 排序PickedWeight[] 和PickerName[],使用降序,经典的冒泡排序,升序:如果 前一个>后一个 ,然后 交换,降序:前一个<后一个 然后交换
- 排序后取前2个姓名和重量,输出。字符串拼接Position[]
- 把获得证书的姓名存入PickerCertificat[],条件PickedWeigth[] >3,同时进行计数。输出总的人数。


Bubble sort 的算法中For index <–1 to GroupSize – 1 应为 For index <– 1 to Last -1,Why?