单向链表
来源:互联网 发布:手机淘宝差评怎么写 编辑:程序博客网 时间:2024/06/05 19:32
链表中的数据是以节点来表示的,每个节点的构成:元素(数据元素的映象) +指针(指示后继元素存储位置),元素就是存储数据的存储单元,指针就是连接每个节点的地址数据。
单向链表
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
//创建单链表
typedef struct student
{
int data;
struct student *next;
}node;
node * creat(){
node *head,*p,*s;
int x,cycle = 1;
head = (node *)malloc(sizeof(node));
p = head;
while(cycle){
cout <<"please input data"
cin >> x;
if(x!=0){
s = (node *)malloc(sizeof(node));
s->data = x;
cout<<s->data;
p->next = s;
p = s;
}
else cycle = 0;
}
head = head->next;
p->next = null;
printf ("\n yyy %d",head->data);
return(head);
}
//测长
int length(node *head){
int n = 0;
node *p;
p = head;
while(p!=null){
p->next = p;
n++;
}
return(n);
}
//打印
void print(node *head){
node * p ,int n;
n = length(node *head);
printf("n\These %d recodes are :\n",n);
p = head;
if (head!= null)
while (head!=null)
{
printf("\n uuu %d",p->data);
p=p->next;
}
}
- 单向链表
- 单向链表倒序
- 单向链表
- 单向链表逆转
- 逆转单向链表
- 单向链表反转
- 单向链表
- 单向链表(ZT)
- 反转单向链表
- 单向链表反转
- 单向链表
- 创建单向链表
- 单向链表反转
- 单向链表
- 单向链表
- 单向链表
- 单向链表
- C++ 单向链表
- 为什么浏览器User-agent总是有Mozilla字样——User-agent String里的历史故事
- ubuntu server安装配置jdk
- 【cocos2d-x-3.1.1系列4】cocos2d-x3.1.1.渲染过程源码简略过程
- Python写的一个爬虫程序
- 让ListView自动滚动
- 单向链表
- 一个匹配数字和字母密码的正则表达式
- java中JNI的使用之JNIEnv类型中方法的使用
- 把二叉树打印成多行
- MySQL基本知识点
- struts2+Hibernate遇到的问题总结
- loop设备及losetup命令介绍
- Unicode文件头的标识
- ASIHTTPRequest系列(二):文件下载