题库首页 › GESP等级认证(Python) › 题目 16628

假设有⼀些物品,每个物品都有⾃⼰的重量,我们需要将这些物品装⼊箱⼦中,每个箱⼦也有⾃⼰的重量限 制。贪⼼算法每次都选择重量最轻的物品放⼊当前最轻的箱⼦中,如果箱⼦可以装下,就放⼊;如果箱⼦不能装 下,就尝试下⼀个箱⼦,直到找到可以放⼊的箱⼦。下列贪⼼算法程序中,横线处应该填⼊的是( )。

假设有⼀些物品,每个物品都有⾃⼰的重量,我们需要将这些物品装 题目配图
A:if not taken[i] and box[0] >= items[i]:
B:if not taken[0] and box[0] >= items[i]:
C:if not taken[i] and box[i] >= items[0]:
D:if not taken[0] and box[0] >= items[i]:

正确答案:A

试卷来源:202409 CCF-GESP编程能力等级认证Python五级真题

本卷相关题目

在线做题 同科目题库