没有合适的资源?快使用搜索试试~ 我知道了~
单链表操作算法举例,单链表操作算法举例
需积分: 9 0 下载量 73 浏览量
2011-07-15
17:04:59
上传
评论
收藏 2KB TXT 举报
温馨提示
试读
4页
链表操作举例,部分源代码 #include<stdio.h> #include<iostream> using namespace std; #define elemtype int typedef struct lnode { elemtype data; struct lnode *next; }lnode,*linklist; void create_list(linklist &l) { //create a linklist with a header int number; lnode *p; l=(lnode*)malloc(sizeof(lnode)); l->next=NULL; cout<<"Input the number:"; cin>>number; for(int i=0;i<number;i++) { p=(lnode*)malloc(sizeof(lnode)); cout<<"Input the data:"; cin>>p->data; p->next=l->next; l->next=p; } }//end of create_list
资源推荐
资源详情
资源评论
#include<stdio.h>
#include<iostream>
using namespace std;
#define elemtype int
typedef struct lnode
{
elemtype data;
struct lnode *next;
}lnode,*linklist;
void create_list(linklist &l)
{
//create a linklist with a header
int number;
lnode *p;
l=(lnode*)malloc(sizeof(lnode));
l->next=NULL;
cout<<"Input the number:";
cin>>number;
for(int i=0;i<number;i++)
{
p=(lnode*)malloc(sizeof(lnode));
cout<<"Input the data:";
cin>>p->data;
p->next=l->next;
l->next=p;
}
}//end of create_list
void print(linklist &l)
{
lnode *p;
#include<iostream>
using namespace std;
#define elemtype int
typedef struct lnode
{
elemtype data;
struct lnode *next;
}lnode,*linklist;
void create_list(linklist &l)
{
//create a linklist with a header
int number;
lnode *p;
l=(lnode*)malloc(sizeof(lnode));
l->next=NULL;
cout<<"Input the number:";
cin>>number;
for(int i=0;i<number;i++)
{
p=(lnode*)malloc(sizeof(lnode));
cout<<"Input the data:";
cin>>p->data;
p->next=l->next;
l->next=p;
}
}//end of create_list
void print(linklist &l)
{
lnode *p;
资源评论
三岔口
- 粉丝: 18
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功