⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tochain.cpp

📁 数据结构c++语言描述 Borland C++实现
💻 CPP
字号:


#include<iostream.h>
#include "llist.h"
#include "echain.h"

template<class T>
void ArrayToChain(const LinearList<T>& L, Chain<T>& C)
{// Convert L to a chain C.
 // Do not catch exceptions that might be thrown.
   T x;
   C.Erase(); // empty the chain
   for (int i = L.Length(); i > 0; i--) {
      // copy i'th element of L
      L.Find(i,x);
      C.Insert(0,x);
      }
}

void main(void)
{
   int n = 15;
   LinearList<int> L(20);
   Chain<int> C;
   for (int i = 0; i < n; i++)
      L.Insert(0,i);
   cout << "The formula-based list is" << endl;
   cout << L << endl;

   ArrayToChain(L,C);
   cout << "The chain is" << endl;
   cout << C << endl;
}

⌨️ 快捷键说明

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