数据结构实验之链表三:链表的逆置(SDUT 2118)
2024-09-05 05:27:59
#include <bits/stdc++.h>
using namespace std;
struct node
{
int data;
struct node *next;
};
int main()
{
int n;
struct node *head,*p;
head = new node;
head -> next = NULL;
while(~scanf("%d", &n))
{
if(n == -1)
break;
p = new node;
p -> next = NULL;
p -> data = n;
p -> next = head -> next;
head -> next = p;
}
for(p = head -> next ; p != NULL; p = p -> next)
{
if(p == head -> next)
printf("%d",p->data);
else
printf(" %d",p->data);
}
printf("\n");
return 0;
}
最新文章
- struct 大小计算
- [javaweb]Java过滤器与包装设计模式的实用案例.
- Oracle Merge Into 用法详解
- ffmpeg无法接收组播流问题处理
- C#_约束 实现可排序单链表
- c中计时的几种方法
- JAVA的节点流和处理流以及流的关闭顺序
- 关于<;%@ include file="; "; %>;与<;jsp:include page=";";>;<;/jsp:include>;中的那些问题?
- Redis数据类型之List(三)
- android studio 目录结构讲解
- 记录一次有意思的XSS过滤绕过2
- [Swift]LeetCode135. 分发糖果 | Candy
- Neutron :默认通过 dnsmasq 实现 DHCP 功能----Namespace
- hive 表锁和解锁
- gd_t , bd_t 结构分析
- code128 C语言实现
- 阿里云ECS安装Kubernetes问题收集与解答
- 构建BSP (boardsupport packet)
- 动态链接库 —— Dll 基础
- moment.js使用方法总结
热门文章
- MySQL 数据库面试题
- 由[].slice.call()引发的思考
- Java 并发进阶常见面试题总结
- c#本地文件配置xml
- 验证组件FluentValidation的使用示例
- Marketing Cloud demo环境和API使用方法说明
- PHP 求两个日期之间相差的天数、月数
- 阿里云Ubuntu下tomcat8.5配置SSL证书
- Image Processing and Analysis_8_Edge Detection:Theory of Edge Detection ——1980
- 03.Zabbix应用服务监控