SDUT 1138 单链表操作A
来源:互联网 发布:开根号的算法 编辑:程序博客网 时间:2024/06/05 20:42
点击打开链接
#include <bits/stdc++.h>using namespace std;int n, m;struct node{ int data; node *next;};node *head, *tail, *p;node *creat(int n);void print(node *head);node *del(node *head, int m);int main(){ cin >> n; head = creat(n); print(head); cin >> m; head = del(head, m); print(head); return 0;}node *creat(int n){ head = new node; tail = head; while(n --) { p = new node; cin >> p -> data; tail -> next = p; tail = p; } tail -> next = NULL; return head;}node *del(node *head, int m){ node *q; p = head -> next; tail = head; while(p) { if(p -> data == m) { tail -> next = p -> next; p = tail -> next; n--; } else { tail = tail -> next; p = p -> next; } } return head;}void print(node *head){ cout << n << endl; p = head -> next; while(p) { if(p -> next) { cout << p -> data << ' '; } else { cout << p -> data << endl; } p = p -> next; }}
0 0
- SDUT 1138 单链表操作A
- SDUT 1138 数据结构上机测试2-1:单链表操作A
- [SDUT](1138)数据结构上机测试2-1:单链表操作A ---链表操作(线性表)
- sdut oj1138 数据结构上机测试2-1:单链表操作A
- 【1138】数据结构上机测试2-1:单链表操作A(顺序建表+删除节点)(SDUT)
- SDUT 1139 单链表操作B
- A(SDUT 2892)
- SDUT OJ -2892 A
- SDUT 3315 a
- sdut 3553 sdut第八届校赛--A*B
- sdut oj1139 数据结构上机测试2-2单链表操作B
- SDUT 2413:n a^o7 !
- A+B Problem (sdut oj)
- SDUT 2017 个人排位赛---A
- SDUT 2413-n a^o7 !
- SDUT_OJ_1138-单链表操作A
- 单链表操作A
- 【MAP模拟】SDUT 1471 A + B problem
- centos6 安装 php7
- 计算机中丢失opencv_core2410d.dll
- JavaScript:正则表达式
- Unity中协程的运行
- Linux信号列表详解
- SDUT 1138 单链表操作A
- 互联网广告综述之点击率特征工程
- 我心中的少林
- Linearlayout 中layout_gravity不起作用问题
- MAVEN项目创建
- 路由器接口配置与管理——1
- 排列
- Windows CMD和bat中特殊符号的作用
- 用modprobe 加载模块时,提示模块找不到的问题