跳到主要内容

Lesson 48: Card reader

English

Is this card allowed?

  • Many doors open with a card. The reader gets the card's ID number and looks for it in a list of allowed IDs.
  • The list is an array. To find an ID, the program looks at each item in turn: a linear search.
  • Arrays have a fixed size, so before adding a new card the program must check that there is room.

Words for this lesson

Word Meaning
array many values under one name, by index
linear search check each item, one after another
found a flag: true once the item is seen
SIZE how many items the array can hold

登录或创建账户

IGCSE, A-Level & AP