• <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>
            ccyy's coding zone
            往前走,不要留戀路邊的風景.
            posts - 25,comments - 9,trackbacks - 0
               今天微軟電面...有一個題目是將鏈表反轉(zhuǎn),返回頭結(jié)點...差點嗝屁..于是把鏈表糾結(jié)了一下...
            #include<stdio.h>
            #include<string.h>
            #include<stdlib.h>
            struct st
            {
            int data;
            struct st *next;
            };
            //reverse list
            struct st *reverse(struct st *head)
            {
            struct st *p=head->next,*q;
            struct st *Head;
            q=p->next;
            p->next=NULL;
            Head=p;
            p=q;
            while(p!=NULL)
            {
            q=p->next;
            p->next=Head;
            Head=p;
            p=q;
            }
            head->next=Head;
            return head;
            }
            //insert list
            void Insert(struct st *head,int x, int i)
            {
            struct st *p=head->next,*q=head;
            i--;
            while(i--)
            {
              q=p;
              p=p->next;
            }
            struct st *now = (struct st*)malloc(sizeof(struct st));//
            now->data=x;
            now->next=p;
            q->next=now;

            }
            //delete list
            void Delete(struct st *head, int x)
            {
            struct st *p=head->next,*q=head;
            while(p!=NULL)
            {
            if(p->data==x)
            {
            q->next=p->next;
            }
            q=p;
            p=p->next;
            }
            }

            int main()
            {
            int n,m,i,j;
            struct st head;
            head.next=NULL;
            for(i=1;i<=8;i++)
            {
            insert(&head,i,i);
            }
            struct st *Head=reverse(&head);
            struct st *p=Head->next;
            while(p!=NULL)
            {
            printf("%d\n",p->data);
            p=p->next;
            }
            Insert(&head,10,1);
            Delete(&head,4);
            Delete(&head,10);
            Delete(&head,8);
            p=Head->next;
            while(p!=NULL)
            {
            printf("%d\n",p->data);
            p=p->next;
            }
            return 0;
            }
            posted on 2010-07-22 21:55 ccyy 閱讀(125) 評論(0)  編輯 收藏 引用
            久久精品国产久精国产思思| 国产成人久久久精品二区三区| 亚洲国产一成久久精品国产成人综合 | 中文字幕一区二区三区久久网站 | 久久精品无码av| 久久亚洲美女精品国产精品| 久久国产精品-国产精品| 久久精品国产清自在天天线| 亚洲人成伊人成综合网久久久| 精品国际久久久久999波多野| 久久九九久精品国产| 久久人爽人人爽人人片AV| 精品国产婷婷久久久| 久久久久亚洲av无码专区喷水 | 亚洲国产精品一区二区久久hs| 国产精品18久久久久久vr| 国产精品久久新婚兰兰| 一本一道久久精品综合| 久久午夜无码鲁丝片| 久久综合偷偷噜噜噜色| 国内精品伊人久久久久影院对白| 亚洲AV日韩精品久久久久| 无码国内精品久久综合88| 狠狠色丁香婷婷综合久久来来去| 久久精品国产亚洲AV无码偷窥| 国产精品久久久久蜜芽| 久久亚洲色一区二区三区| 欧美久久天天综合香蕉伊| 国产精品伦理久久久久久| 久久福利青草精品资源站| 国内精品久久久久久野外| 精品无码久久久久国产| 国内精品久久久久| 久久国产精品99久久久久久老狼 | 国产一区二区三精品久久久无广告| 久久精品国产亚洲AV麻豆网站 | 久久精品国产清自在天天线| 久久久精品免费国产四虎| 久久中文字幕人妻丝袜| 伊人色综合久久天天人守人婷| 综合久久精品色|