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

你可能感兴趣的文章
推荐一个算法网站
查看>>
Python操作MySQL+Redis+MongoDB
查看>>
2017.6.30 Note replace innerHTML split() join()
查看>>
过滤关键词(中间有空格一样过滤)
查看>>
sql 当重复的数据有多条时,保留一条,删除其他重复
查看>>
RFC 4627 JSON
查看>>
Django入门与实践
查看>>
一些面试题(3)
查看>>
算法一枚
查看>>
Spin lock 与mutex 的区别--2011.01.06
查看>>
Java resources
查看>>
python--异常处理
查看>>
MongoDB 之 你得知道MongoDB是个什么鬼 MongoDB - 1
查看>>
数论只会GCD。。。
查看>>
UVA 12506 Shortest Names
查看>>
利用 jQuery 来验证密码两次输入是否相同
查看>>
WIN7用户登录背景修改方法
查看>>
[转]HTTP请求行、请求头、请求体详解
查看>>
java基础之 超类Object
查看>>
C#中用webBrowser控件实现对Google地图的定位访问
查看>>