链表 头插法,尾插法
2015-07-13 15:23
260 查看
<span style="font-family:SimSun;font-size:18px;">/*#include <stdio.h> #include <stdlib.h> struct Node//链表的尾插法 { char date; Node *next; }; int main() { Node *p,*q,*x,*head; char c; p=(Node *)malloc(sizeof(Node)); p->next=NULL; head=p; while(scanf("%c",&c)) { if(c=='\n') break; q=(Node *)malloc(sizeof(Node)); q->date=c; p->next=q; p=p->next; } p->next=NULL; x=head->next; while(x!=NULL) { printf("%c",x->date); x=x->next; } printf("\n"); return 0; }*/ #include <stdio.h> #include <stdlib.h> struct Node//链表的头插法 { char date; Node *next; }; int main() { Node *p,*q,*x,*head; char c; head=(Node *)malloc(sizeof(Node)); head->next=NULL; while(scanf("%c",&c)) { if(c=='\n') break; p=(Node *)malloc(sizeof(Node)); p->date=c; p->next=head->next; head->next=p; } q=head->next; while(q!=NULL) { printf("%c",q->date); q=q->next; } printf("\n"); return 0; }</span>
相关文章推荐
- stl之multiset,multimap
- uvalive 6657 GCD XOR
- eclipse安装Veloeclipse(Velocity编辑插件)
- view转bitmap
- Android 滑动抽屉
- 如何配置Bitnami Redmine中的svn
- 在Ruby中查找和执行方法
- JAVA基础之理解JNI原理
- 还在用Toast?你Out啦,试试Snackbar吧!
- Tomcat能够在eclipse里启动,但是不能访问首页的问题
- Eclipse4.4 创建Maven项目
- 协议的实现
- 经典管理学定律6 - 刺猬法则
- Qt批量操作Excel
- iOS开发系列--UITableView全面解析
- UITableViewCell自适应高度
- 如何优化cocos2d/x程序的内存使用和程序大小
- sqlist顺序表
- dsfgsdfg
- 通信错误:(-1)[描述:无法解析路由器DDNS地址,请检查DDNS状态.] 解析办法