• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-48  評論-259  文章-1  trackbacks-0

            #include "head.h"
            #include "iostream.h"


            #define LIST_INIT_SIZE 100

            template <class ElemType>
            class SqList
            {
              private:
               ElemType *elem;
               int length;
                  int listsize;
              public:
               SqList(int max=LIST_INIT_SIZE);
               ~SqList(){delete[] elem;}
                  void ClearList();
                  Status input(int n);
                  Status output();
                  Status ListEmpty();
                  int    ListLength();
                  ElemType GetElem(int i);
                  Status NextElem(ElemType i,ElemType &next_e);
                  Status ListInsert(int i,ElemType e);
                  Status ListDelete(int i,ElemType &e);
               Status inver();// 逆置
                  //Status MergeList(SqList La,SqList Lb);
            };
            template <class ElemType> SqList<ElemType>::SqList(int max)
            {
              listsize=max;
              length=0;
              elem=new ElemType[listsize];
            };
            template <class ElemType> void SqList<ElemType>::ClearList()
            {
              delete[] elem;
              elem=new ElemType[listsize];
              length=0;
            };
            template <class ElemType> Status SqList<ElemType>::input(int n)
            {
              if(n<=0) return ERROR;
              for(int i=0;i<n;i++)
              {
                cout<<"輸入第"<<i+1<<"個數:";
             cin>>elem[i];
              }
              length=n;
              return OK;
            };
            template <class ElemType> Status SqList<ElemType>::output()
            {
              if(length==0) return ERROR;
              else
              {
                for(int i=0;i<length;i++)
             {
               cout<<elem[i]<<"->";
             }
             cout<<"NULL"<<endl;
              }
              return OK;
            };
            template <class ElemType> Status SqList<ElemType>::ListEmpty()
            {
              if(length==0) return TRUE;
               else return FALSE;
            };
            template <class ElemType> int SqList<ElemType>::ListLength()
            {
              return length;
            };
            template <class ElemType> ElemType SqList<ElemType>::GetElem(int n)
            {
             ElemType e;
              if(length==0) return ERROR;
              if(n<1||n>ListLength()) return OVERFLOW;
              e=elem[n-1];
              return e;
            };
            template <class ElemType> Status SqList<ElemType>::NextElem(ElemType loc_e,ElemType &next_e)
            {
              if(length==0) return ERROR;
              for(int i=1;loc_e!=elem[i-1];i++);
              if(i==length) return OVERFLOW;
              next_e=elem[i];
              return OK;
            };
            template <class ElemType> Status SqList<ElemType>::ListInsert(int i,ElemType e)
            {
              if(i<1||i>length)  return ERROR;
              if(listsize==length) return OVERFLOW;
              for(int n=length-1;n>=i-1;n--)
               elem[n+1]=elem[n];
              elem[i-1]=e;
              length++;
              return OK;
            };
            template <class ElemType> Status SqList<ElemType>::ListDelete(int i,ElemType &e)
            {
              if(i<1||i>length)  return ERROR;
              e=elem[i-1];
              for(int n=i-1;n<length-1;n++)
               elem[n]=elem[n+1];
              length--;
              return OK;
            };
            template <class ElemType> Status SqList<ElemType>::inver()
            {
              int i,m,n;
              ElemType temp;
              n=length;
              m=n/2;
              for(i=0;i<m;i++)
              {
                temp=elem[i];elem[i]=elem[n-i-1];elem[n-i-1]=temp;
              }
              return OK;
            };

            posted on 2007-06-07 19:44 星夢情緣 閱讀(572) 評論(0)  編輯 收藏 引用 所屬分類: 數據結構的所有實現程序
            97久久香蕉国产线看观看| 亚洲国产成人久久笫一页| 亚洲精品无码久久久久久| 亚洲精品无码久久久影院相关影片| 一本一本久久A久久综合精品 | 久久青青草视频| 狠狠色婷婷久久一区二区三区| 国产午夜久久影院| 亚洲精品无码久久毛片| 久久Av无码精品人妻系列| 精品综合久久久久久88小说 | 99久久精品午夜一区二区| 精品久久久久久无码人妻热| 国产成年无码久久久免费| 91久久香蕉国产熟女线看| 久久久久亚洲AV成人片| 欧美粉嫩小泬久久久久久久| 国产精品对白刺激久久久| 精品久久久久成人码免费动漫| 国产成人久久精品区一区二区| 2021国产精品午夜久久| 国产精久久一区二区三区| 99久久精品国产高清一区二区 | 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 色狠狠久久AV五月综合| 国产亚洲精午夜久久久久久| 人妻精品久久无码区| 久久毛片一区二区| 欧美午夜A∨大片久久 | 日本精品久久久久影院日本| 久久免费精品视频| 国产99久久精品一区二区| 久久99国产综合精品| 午夜精品久久久久久久久| 狠狠精品久久久无码中文字幕| 亚洲综合久久夜AV | 色8激情欧美成人久久综合电| 欧美精品一区二区久久| 少妇被又大又粗又爽毛片久久黑人 | 国内精品久久久久影院免费| 国产欧美一区二区久久|