sequenti.cpp

来自「数据结构与程序设计教材源码 数据结构与程序设计教材源码」· C++ 代码 · 共 19 行

CPP
19
字号
Error_code sequential_search(const List<Record> &the_list,
                             const Key &target, int &position)
/* 
Post: If an entry in the_list has key equal to target, then return
      success and the output parameter position locates such an entry
      within the list.

       Otherwise return not_present and position becomes invalid.
*/
{
   int s = the_list.size();
   for (position = 0; position < s; position++) {
      Record data;
      the_list.retrieve(position, data);
      if ((Key) data == target) return success;
   }
   return not_present;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?