シングルチェーンテーブルの作成



//      
//    :               
//               
//    ctrl+z    

#include <stdio.h>
#include <malloc.h>

typedef int ElemType;
//        
typedef struct Node{
	int data; //   
	struct Node *next; //   
}Node,*linkList;


//    
//   ,          ,        
linkList create_List()
{
	//     
	linkList head = (linkList)malloc(sizeof(Node));
	head->next = NULL;
	printf("       :");
	linkList list = (linkList)malloc(sizeof(Node));
	while(scanf("%d", &list->data) != EOF)
	{
		list->next = head->next;
		head->next = list;
		list = (linkList)malloc(sizeof(Node));
	}
	return head;
}

//       
void printList(linkList list)
{
	linkList current = list->next;
	printf("       :
"); while(current != NULL) { printf("%d ", current->data); current = current->next; } printf("
"); } int main() { linkList list = create_List(); printList(list); return 0; }