博客
关于我
强烈建议你试试无所不能的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

你可能感兴趣的文章
linux 安装mysql数据库——yum安装法
查看>>
Several ports (8005, 80, 8009) required by Tomcat v6.0 Server at localhost are already in use
查看>>
事件监听器
查看>>
设计模式之单例设计模式
查看>>
异常的基本概念
查看>>
iOS 离屏渲染学习笔记
查看>>
iOS Xib布局某些控件显示或隐藏<约束的修改>
查看>>
苹果端手机微信页面长按图片无法保存的解决方案
查看>>
球的移动(move)
查看>>
页面禁止双击选中
查看>>
打印流
查看>>
TCP/IP模型的一个简单解释
查看>>
解开最后期限的镣铐(转载)
查看>>
Kth Smallest Element in a BST
查看>>
ubuntu14.04利用aliyun安装docker
查看>>
iphone-命令行编译之--xcodebuild
查看>>
Plan : 破晓
查看>>
GNU make
查看>>
Visual Studio 2008 不能更改安装目录的原因
查看>>
threejs学习笔记04---相机动
查看>>