链表头结点

int pos;

cin >> pos;

if (pos < 1 || pos > L->length) { // 假设链表头节点存储length属性表示链表长度

cout << "Sorry,the position to be deleted is invalid!" << endl;

return ERROR;

}

LinkList p = L;

int cnt = 0;

while (p != NULL && cnt < pos - 1) {

p = p->next;

cnt++;

}

LinkList q = p->next;

p->next = q->next;

delete q;

LinkList cur = L->next;

while (cur != NULL) {

cout << cur->data.no << " " << cur->data.name << " "

<< fixed << setprecision(2) << cur->data.price << endl;

cur = cur->next;

}

return OK;

相关推荐
码出财富21 小时前
SpringBoot 内置的 20 个高效工具类
java·spring boot·spring cloud·java-ee
我是小疯子6621 小时前
Python变量赋值陷阱:浅拷贝VS深拷贝
java·服务器·数据库
森叶21 小时前
Java 比 Python 高性能的原因:重点在高并发方面
java·开发语言·python
二哈喇子!21 小时前
Eclipse中导入外部jar包
java·eclipse·jar
微露清风21 小时前
系统性学习C++-第二十二讲-C++11
java·c++·学习
进阶小白猿1 天前
Java技术八股学习Day20
java·开发语言·学习
gis开发1 天前
【无标题】
java·前端·javascript
Wpa.wk1 天前
性能测试 - 搭建线上的性能测试环境参考逻辑图
java·经验分享·测试工具·jmeter·性能测试
代码村新手1 天前
C++-类和对象(中)
java·开发语言·c++
葵花楹1 天前
【JAVA课设】【游戏社交系统】
java·开发语言·游戏