链表存储——小练习
来源:互联网 发布:如何做好酒店网络销售 编辑:程序博客网 时间:2024/06/05 05:07
多编码来强化编程流程
#include <stdio.h>#include <stdlib.h>#include <string.h>struct list{ char name[20]; struct list * next;};typedef struct list list;list* createlist(){ list *head,*p,*q; head=(list*)malloc(sizeof(list)); if(NULL==head) { printf("memory allocate failure!\n"); free(head); return NULL; } q=head; printf("please input a character!\n"); char name[20]={0};// scanf("%s\n",name); gets(name); while(strlen(name)!=0) { p=(list*)malloc(sizeof(list)); if(NULL==p) return head; strcpy(p->name,name); q->next=p;//与头节点链接 q=p;//头节点向后挪动一个位置 printf("continue? if you want to move on,please input what you want to input,if not,please input enter.\n");// scanf("%s",name); gets(name); } q->next=NULL; return head;}void print(list *head){ list *q; q=head->next; while(q!=NULL) { printf("%s\n",q->name); q=q->next; }}int main(){ list *head=NULL; head=createlist(); print(head); free(head); return 0;}
1 0
- 链表存储——小练习
- 反射——小练习
- 小练习——九九乘法表
- C++小练习—Dijkstra
- 存储过程的一些小练习
- 数据结构(16)——邻接表存储练习
- oracle笔记——存储函数练习
- 一个链表的小练习
- 双向链表的小练习
- 寒假小练习——破译密码
- 小练习——杨辉三角
- 汇编 —— AT&T小练习
- JAVA小练习——汉诺塔
- Python小练习四——计算器
- python小练习六——小游戏
- 阻止冒泡——小练习
- LinuxC小练习——计算器
- C++小练习—找零钱问题
- VS2013+QT5+opencv3.1显示摄像头
- 线程、线程信号量等常用函数小结
- ubuntu下如何处理出现“ unable to execute ./DrClientLinux: No such file or directory”,“没有那个文件或目录”的问题。
- Python数据分析常用代码收集
- leetCode练习(111)
- 链表存储——小练习
- java.util.Calendar/java.util.GregorianCalendar
- POJ 3279 二进制搜索
- Android之XML解析应用
- Linux的LCD驱动
- Java I/O流
- 【打表计划】【小澳的坐标系】 矩阵快速幂
- IOS 一个继承UINavigationController的子类
- 总结29