单链表的建立,把a~z 26个字母插入到链表中,并且倒叙,还要打印

#include<stdio.h> 
#include<stdlib.h>

typedef struct linklist 
{
	char ff;
	struct linklist *next;
}Node;    
typedef Node* Linklist;

int main()
{
	Linklist L, new;
	L = (Linklist)malloc(sizeof(Node));
	L->next = NULL;
	int i;
	for(i = 0; i < 26; i++)
	{
		new = (Linklist)malloc(sizeof(Node)); 
		new->ff = 'a' + i;
		new->next = L->next;
		L->next = new;
	}
	while(L->next)
	{
		printf("%c ", L->next->ff);
		L = L->next;
	}
	printf("\n");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/costeeer/article/details/79165853
今日推荐