题目
题目

(72ab92) AP CS Principles (72ab92) AP 计算机科学原理 1.2 AP-Style MC Practice 1.2 AP 风格的 MC 练习

单项选择题

Consider the following two implementations of the same algorithm, each written in a different language. 考虑以下同一算法的两种实现,每种实现都使用不同的语言编写。 Language A:  语言 A: Calculate the average daily rainfall for the week (averageRainfall) by adding together the rainfall totals for each of the 7 days of the week (sun, mon, tue, wed, thu, fri, and sat) and dividing the sum by 7. 将一周 7 天(周日、周一、周二、周三、周四、周五和周六)每天的降雨量总数相加,然后将总和除以 7,计算出一周的平均每日降雨量(平均降雨量)。 Language B:  语言 B: Take the total amount of rain from each day of the week (sunday, monday, tuesday, wednesday, thursday, friday and saturday) and then average them together to get the average daily rainfall for the week (averageRainfall). 计算一周中每天(星期日、星期一、星期二、星期三、星期四、星期五和星期六)的总降雨量,然后将其平均,得到该周的平均每日降雨量(平均降雨量)。 Which of the following statements about these two implementations is true? 以下关于这两种实现的说法中哪一项是正确的?

选项
A.Language A is ambiguous because it is unclear what sun, mon, tue, wed, thu, fri, and sat refer to in context with the problem. 语言 A 具有歧义,因为不清楚 sun、mon、tue、wed、thu、fri 和 sat 在问题上下文中指的是什么。
B.Language B is ambiguous because the process of “average” is not explained well 语言 B 有歧义,因为“平均”的过程没有得到很好的解释
C.The algorithms in both languages are ambiguous because they do not specify the actual values of the seven daily rainfall totals. 这两种语言的算法都比较模糊,因为它们没有指定七天降雨总量的实际值。
D.Neither of these languages is clear enough that a programmer could write a correct solution in a high-level programming language. 这两种语言都不够清晰,程序员无法用高级编程语言编写出正确的解决方案。
查看解析

查看解析

标准答案
Please login to view
思路分析
First, restating the scenario helps frame the evaluation: we have two algorithmic implementations described in different languages that compute the average daily rainfall over a week. The question asks which statement about these implementations is true. Option 1: Language A is ambiguous because it is unclear what sun, mon, tue, wed, thu, fri, and sat refer to in context with the problem. - This claim focuses on the identifiers for the days in Language A. The description explicitly mentions seven days (sun, mon, tue, wed, thu, fri, sat) as the quantities to be summed, so the intent is clear: these are the daily rainfall totals for each day of the week. The idea of summing these seven values and dividing by 7 to get an average is a standard, wel......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!