#include<stdio.h>
#include<stdlib.h>
typedef struct List
{
int data;
struct List *next;
} List;
void HeadCreatList(List *L)
{
List *s;
L->next = NULL;
int i;
for ( i = 0; i < 5; i++)
{
s = (struct List*) malloc(sizeof(struct List));
s->data = 'A'+i;
s->next = L->next;
L->next = s;
}
}
void TailCreatList(List *L)
{
List *s, *r;
r = L;
int i;
for ( i = 0; i < 5; i++)
{
s = (struct List*) malloc(sizeof(struct List));
s->data = 'A'+i;
r->next = s;
r = s;
}
r->next = NULL;
}
void DisPlay(List *L)
{
List *p = L->next;
while (p != NULL)
{
printf("%c ", p->data);
p = p->next;
}
printf("\n");
}
int main()
{
List *L1, *L2;
L1 = (struct List*) malloc(sizeof(struct List));
L2 = (struct List*) malloc(sizeof(struct List));
HeadCreatList(L1);
DisPlay(L1);
TailCreatList(L2);
DisPlay(L2);
}
04-26
234
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-23
7624
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-28
4万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-08
1335
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交