• <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
               今天微軟電面...有一個題目是將鏈表反轉,返回頭結點...差點嗝屁..于是把鏈表糾結了一下...
            #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 閱讀(117) 評論(0)  編輯 收藏 引用
            日韩人妻无码一区二区三区久久99| 91精品国产高清91久久久久久| 激情久久久久久久久久| 欧美久久久久久精选9999| 国产精品久久久久a影院| 亚洲∧v久久久无码精品| 老司机国内精品久久久久| 亚洲а∨天堂久久精品9966| 久久婷婷五月综合色高清 | 少妇久久久久久久久久| 久久不射电影网| 99精品国产免费久久久久久下载| 国产成人久久激情91| 亚洲欧洲久久av| 国产精品无码久久四虎| 精品国产乱码久久久久久郑州公司 | 久久亚洲精品中文字幕三区| 久久天天躁狠狠躁夜夜2020| 精品国产一区二区三区久久久狼 | 国产亚洲欧美成人久久片| 狠狠色丁香久久婷婷综合_中 | 久久天天躁狠狠躁夜夜网站 | 99国内精品久久久久久久| 久久夜色精品国产噜噜噜亚洲AV | 狠狠色噜噜狠狠狠狠狠色综合久久| 伊人久久大香线蕉综合5g| 色成年激情久久综合| 久久人人爽人人爽人人AV东京热 | 99久久国产热无码精品免费| 久久天天躁狠狠躁夜夜2020一| 久久99国产一区二区三区| 女人香蕉久久**毛片精品| 久久精品国产亚洲av麻豆小说| 久久久久国产精品嫩草影院| 亚洲精品WWW久久久久久| 成人免费网站久久久| 久久久久无码精品国产| 无码国内精品久久人妻| 久久精品国产亚洲AV香蕉| 成人久久久观看免费毛片 | 久久这里的只有是精品23|