• <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 星夢情緣 閱讀(565) 評論(0)  編輯 收藏 引用 所屬分類: 數據結構的所有實現程序
            99久久免费国产精品| 嫩草伊人久久精品少妇AV| 久久亚洲国产午夜精品理论片| 一级做a爰片久久毛片人呢| 久久中文精品无码中文字幕| 午夜久久久久久禁播电影| 国产精品久久国产精麻豆99网站| 精品国产青草久久久久福利| 99久久精品国产一区二区 | 久久影视国产亚洲| 久久综合给合久久国产免费| 久久久久综合中文字幕| 国产精品久久久久久久久鸭| 久久精品卫校国产小美女| 久久亚洲国产精品一区二区| 久久久久人妻一区二区三区vr| 日韩AV毛片精品久久久| 国产精品狼人久久久久影院| 国产精品久久久久国产A级| 青青草原综合久久大伊人| 久久精品亚洲欧美日韩久久| 精品久久久中文字幕人妻| 国产呻吟久久久久久久92| 久久精品无码午夜福利理论片| 亚洲欧美国产精品专区久久 | 精品少妇人妻av无码久久| 人妻无码精品久久亚瑟影视| 久久综合伊人77777麻豆| 国产叼嘿久久精品久久| 91久久精品国产91性色也| 精品久久久久久国产| 久久精品国产免费| 久久99毛片免费观看不卡| 久久国产精品-久久精品| 国产精品女同久久久久电影院| 久久男人Av资源网站无码软件 | 欧美日韩中文字幕久久伊人| 精品国产一区二区三区久久| 99久久人人爽亚洲精品美女| 久久成人永久免费播放| 亚洲欧美一区二区三区久久|