题目1181:遍历链表
来源:互联网 发布:淘宝盗版商品是啥意思 编辑:程序博客网 时间:2024/06/02 19:28
#include <cstdio>#include <string>#include <cstring>#include <iostream>#include <algorithm>using namespace std;typedef struct node node;struct node{ int data; struct node * next;};node* creat(int n){ node *head=new node; head->next=NULL; node *p=head; while(n-->0) { node *t=new node; scanf("%d",&t->data); t->next=p->next; p->next=t; p=t; } return head;}void look(node * head){ node * p=head->next; while(p->next) { printf("%d ",p->data); p=p->next; } printf("%d\n",p->data);}void destory(node *head){ node * p=head; while(p) { node *t=p; p=p->next; delete t; }}void Sort(node *head){ node *p,*q; for(p=head->next; p; p=p->next) { for(q=head->next; q; q=q->next) { if(p->data<q->data) { int t=p->data; p->data=q->data; q->data=t; } } }}int main(){ int n; while(scanf("%d",&n)!=EOF) { node* head=creat(n); Sort(head); look(head); destory(head); } return 0;}
0 0
- 题目1181:遍历链表
- 题目1181:遍历链表
- 题目1181:遍历链表
- 题目1181:遍历链表
- 题目1181:遍历链表
- 题目1181:遍历链表
- 题目1181:遍历链表
- 【九度】题目1181:遍历链表
- 九度OJ 题目1181:遍历链表
- 九度OJ 题目1181:遍历链表
- 【九度OJ】题目1181:遍历链表 解题报告
- 数据结构题目,后续遍历
- (题目32)题目1078:二叉树遍历
- 题目32:二叉树遍历
- 题目1184:二叉树遍历
- 题目1084: 二叉树遍历
- 题目1:二叉树遍历
- 题目1078:二叉树遍历
- POJ 1328 3190 贪心 优先队列
- 蓝桥杯 历届真题之剪格子(dfs)
- 第一篇博文,写一下今天笔试的事
- Oracle PL/SQL编程详解之三: PL/SQL流程控制语句
- 15.线程面试题三
- 题目1181:遍历链表
- 从蓝桥凑算式得到的全排列新发现
- 扔飞镖游戏
- Release版的控制台程序关闭时提示“已停止工作”
- 蓝桥杯练习 ALGO-132 算法训练 Maze
- leetcode 413
- Ubuntu创建快捷方式语法
- 无意中发现的sql server 存储过程加密破解方法
- node.js学习(二十三、mongodb命令)