帮忙写个C语言程序!题目在下面!关于链表的。还没学,题目:“建立一个链表,逐个输入字符,每一个字符存放在一个链。
Posted By : Admin
2016-05-16 21:16
网友问:帮忙写个C语言程序!题目在下面!关于链表的。还没学,题目:“建立一个链表,逐个输入字符,每一个字符存放在一个链。
答:#include "stdio.h"#include "string.h"#include #include #define RETURN 13typedef struct node{ char key; struct node *pNext;}NODE, LIST;void Print(LIST *head){ NODE *p = head; while (p != NULL) { printf("%c", p->key); p = p->pNext; } printf("n");}LIST * CreateList(){ NODE *head, *p, *last; char in; in = getche(); if(in == RETURN){return NULL; }else{ head = (NODE *) malloc(sizeof(NODE)); head->key = in; head->pNext = NULL; last = head; } do{ in = getche(); if (in == RETURN) { printf("nYour list is:n"); Print(head); break;
本文链接:http://www.wanwan45.cn/q/z3/y/3127025210.shtml