码迷,mamicode.com
首页 > 其他好文 > 详细

第三十四次发博不知道用什么标题好

时间:2019-05-18 00:22:39      阅读:80      评论:0      收藏:0      [点我收藏+]

标签:clu   struct   for   oid   ++   typedef   free   pre   data   

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 typedef int Elemtype;
 4  typedef struct node{
 5      int data;
 6      struct node *next;
 7  }Slink; 
 8  
 9  void Creatlist(Slink *L)
10  {
11      L->next=NULL;
12  }
13  
14  Slink * Creatlist(Slink *L,Elemtype a[],int n)            //头插 
15  {
16      Slink *s;
17      int i;
18      for(i=0;i<n;i++)
19      {
20          s = (Slink*)malloc(sizeof(Slink));
21         s->data=a[i];
22          s->next=L->next;
23          L->next=s;
24      }
25      return L;
26  }
27  
28  int Insert(Slink *L,Elemtype x,int i)                //插入 
29  {
30      Slink *p=L,*s;
31      int j=0;
32      while(p!=NULL&&j<i=1)
33      {
34          j++;
35          p=p->next;
36      }
37      if(p==NULL)
38      return 0;
39      else
40      {
41          s = (Slink*)malloc(sizeof(Slink));
42          s->data=x
43          s->next=p->next;
44          p->next=s;
45          return 1;
46      }
47  }
48  
49 int Delet(Slink*L,int i)
50  {
51      Slink *p=L,*s;
52      int j;
53      while(p->next!=NULL&&j<i)
54      {
55          j++;
56          p=p->next;
57      } 
58      if(p==NULL)
59      return 0;
60      else
61      {
62          s=p->next;
63         s->next=p->next;
64         free(p);        
65      }
66      
67  }
68  

睡觉

第三十四次发博不知道用什么标题好

标签:clu   struct   for   oid   ++   typedef   free   pre   data   

原文地址:https://www.cnblogs.com/shi-yuan/p/10884302.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!