当前位置:网站首页 > C++编程 > 正文

c++单向链表的创建与操作(c++实现单链表基本操作)

#include <iostream>


#include <cstdio>


#include <cmath>


#include <cstring>


using namespace std;



#define ok 1


#define error 0



typedef int ElemType;


typedef struct LNode {


ElemType data;


struct LNode *next;


}LNode, *LinkList;



int creat(LinkList &L) {


L = new LNode;


L->next = NULL;


int n, i;


cout << "请输入元素个数:" << endl;


cin >> n;


for (i = 1; i <= n; i++) {


LNode *p;


p = new LNode;


cout << "请输入第" << i << "个元素。" << endl;


cin >> p->data;


p->next = L->next;


L->next = p;


}


return ok;


到此这篇c++单向链表的创建与操作(c++实现单链表基本操作)的文章就 介绍到这了,更多相关内容请继续浏览下面的相关 推荐文章,希望大家都能在 编程的领域有一番成就!





























版权声明


相关文章:

  • apc与upc的区别(apc与upc的区别照片)2026-02-11 08:45:06
  • cpu参数对比工具怎么用(cpu参数对比工具怎么用的)2026-02-11 08:45:06
  • pc接头是什么意思(pc接头是什么意思啊)2026-02-11 08:45:06
  • mouse2joystick下载(mouse2joystick载入不了)2026-02-11 08:45:06
  • consolidation翻译(consolidation翻译成英语)2026-02-11 08:45:06
  • cnn是监督还是非监督的(cnn是监督还是非监督的简称)2026-02-11 08:45:06
  • yml文件怎么导入clash(yml文件怎么导入)2026-02-11 08:45:06
  • vs怎么创建c++项目(vs怎么创建一个c++项目)2026-02-11 08:45:06
  • py文件如何生成exe(py文件如何生成 pyc)2026-02-11 08:45:06
  • pdfview怎么转换成图片(pdf怎么转vce)2026-02-11 08:45:06
  • 全屏图片