博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TJU1012
阅读量:4497 次
发布时间:2019-06-08

本文共 1153 字,大约阅读时间需要 3 分钟。

    没什么好说的了,标准链表题。
None.gif
#include
<
iostream
>
None.gif
using
 
namespace
 std;
None.gif
None.gif
class
 LinkedList
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
{
InBlock.gif
public:
InBlock.gif    LinkedList
* Next;
InBlock.gif    
int Number;
InBlock.gif    
int Password;
InBlock.gif    
void DeleteNext();
InBlock.gif    LinkedList
* Append(int Number,int Password);
InBlock.gif    LinkedList(
int Number,int Password);
ExpandedBlockEnd.gif}
;
None.gif
None.gifLinkedList::LinkedList(
int
 Number,
int
 Password)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
{
InBlock.gif    
this->Number=Number;
InBlock.gif    
this->Password=Password;
InBlock.gif    
this->Next=this;
ExpandedBlockEnd.gif}
None.gif
None.gif
void
 LinkedList::DeleteNext()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
{
InBlock.gif    LinkedList
* temp=Next;
InBlock.gif    Next
=temp->Next;
InBlock.gif    delete(temp);
ExpandedBlockEnd.gif}
None.gif
None.gifLinkedList
*
 LinkedList::Append(
int
 Number,
int
 Password)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
{
InBlock.gif    LinkedList
* temp
InBlock.gif        
=new LinkedList(Number,Password);
InBlock.gif    temp
->Next=this->Next;
InBlock.gif    
this->Next=temp;
InBlock.gif    
return temp;
ExpandedBlockEnd.gif}
None.gif
None.gif
int
 main()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
{
InBlock.gif    LinkedList
* head;
InBlock.gif    
int Count,people,Count1,password;
InBlock.gif    
//Construct Linked List
InBlock.gif
    while(cin>>people>>Count)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        cin
>>password;
InBlock.gif        head
=new LinkedList(1,password);
InBlock.gif        
for(Count1=2;Count1<=people;Count1++)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            cin
>>password;
InBlock.gif            head
=head->Append(Count1,password);
ExpandedSubBlockEnd.gif        }
InBlock.gif        
//Exit Queues
InBlock.gif
        while(head->Next != head)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
for(Count1=Count;Count1>1;Count1--)
InBlock.gif                head
=head->Next;
InBlock.gif            cout
<<head->Next->Number<<' ';
InBlock.gif            Count
=head->Next->Password;
InBlock.gif            head
->DeleteNext();
ExpandedSubBlockEnd.gif        }
InBlock.gif        cout
<<head->Number<<endl;
InBlock.gif        delete(head);
ExpandedSubBlockEnd.gif    }
InBlock.gif    
return 0;
ExpandedBlockEnd.gif}

转载于:https://www.cnblogs.com/FancyMouse/articles/219739.html

你可能感兴趣的文章
idea 错误: -source 1.6 中不支持 diamond 运算符的解决办法
查看>>
11个让你吃惊的linux命令
查看>>
Python API
查看>>
混凝土数学第四章之数论学习笔记
查看>>
今天学了下REST相关概念,写个随笔作为记录
查看>>
毕设用到的工具
查看>>
C++学习笔记-STL
查看>>
UVA 11552 Fewest Flops(区间dp)
查看>>
Supervisor安装与配置问题一站式解决
查看>>
jfinal视频目录
查看>>
软件设计师考试历年试题汇总
查看>>
小div在大div中垂直居中,以及div在页面垂直居中
查看>>
有用的导航栏代码
查看>>
语法错误 : 缺少“;”(在“*”的前面) 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int...
查看>>
2015Web前端攻城之路
查看>>
推荐一个算法网站
查看>>
Python操作MySQL+Redis+MongoDB
查看>>
2017.6.30 Note replace innerHTML split() join()
查看>>
过滤关键词(中间有空格一样过滤)
查看>>
sql 当重复的数据有多条时,保留一条,删除其他重复
查看>>