| 
 
TA的每日心情|  | 开心 2014-6-18 08:29
 | 
|---|
 签到天数: 14 天 [LV.3]偶尔看看II 滴水大师  
 
 
	积分2345 
 | 
 
| 题目 
  
 解决代码及点评[cpp] view plaincopy
 ![]() ![]() 
 
 
 <pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"></pre><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code">/************************************************************************/  /*  92. 编程把链表(1)变成链表(2)。 head (1)        data  next       data  next       data  next     记录1              记录2             记录3  data  next      data  next    记录4            记录5  head (2)      data  next       data  next       data  next          记录1              记录2              记录3          data  next       data  next    记录4              记录5     */  /************************************************************************/  #include <stdio.h>  #include <stdlib.h>  #include <math.h>  #include <string.h>    typedef struct  student STU;  struct student  {      int num;      char name[10];      struct student * next;  };  STU * Init92()  {      STU * p=(STU *)malloc(sizeof(STU));      if (p==NULL)      {          return NULL;      }      else          p->next=NULL;      return p;  }  STU *  Insert92(STU * head,int num,char * name)  {   STU * last=head;      if (last==NULL)      {          return NULL;      }      while(last->next!=NULL)          last=last->next;      STU *p=(STU *)malloc(sizeof(STU));      if (p==NULL)      {          return NULL;      }      else      {          p->num=num;          strcpy_s(p->name,name);          last->next=p;          p->next=NULL;          return p;        }  }  void    DeleteNode92(STU* pre,STU *cur)  {      pre->next=cur->next;      free(cur);  }  void    printfNodes92(STU *head)  {      STU *p=head->next;      do       {          printf("%5d",p->num);          p=p->next;      } while (p!=head->next);            printf("\n");  }  void main()  {      STU * A=Init92();      Insert92(A,1,"abc");      Insert92(A,2,"abc");      Insert92(A,3,"abc");      Insert92(A,4,"abc");      STU*p= Insert92(A,5,"abc");      p->next=A->next;      printfNodes92(A);      STU* a;STU* b;STU*c;      a=A->next;      b=a->next;      c=b->next;      STU * temp=A->next->next;      do       {          b->next=a;          a=b;          b=c;          c=c->next;      } while (b!=temp);      printfNodes92(A);              system("pause");  }</pre><br><br><br></pre></pre></pre>  
 
 
 | 
 |