没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
C++单链表基本操作(代码)
#include <iostream>
#include <stdlib.h>
#include <assert.h>
using namespace std;
// list node structure
typedef struct _NODE{
int data;
struct _NODE *next;
}NODE, *PNODE;
// create a list, return the pointer to the head node
PNODE create()
{
PNODE head = NULL;
PNODE current = NULL;
PNODE temp = NULL;
int data = 0;
int cnt = 1;
temp = new NODE;
assert(temp != NULL);
cout << "Please input numbers, end with 0" << endl;
cin >> data;
temp->data = data;
while(temp->data != 0)
{
if(cnt == 1)
{
// head node
current = temp;
head = current;
}else{
current->next = temp;
}
current = temp;
temp = new NODE;
assert(temp != NULL);
cin >> data;
temp->data = data;
cnt++;
资源评论
- wywywy20122015-03-13总结的很好 涵盖了基本的链表操作
lflqflpf
- 粉丝: 1
- 资源: 41
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功