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

你可能感兴趣的文章
C++ 通过对象方式 、指针方式两种方式去访问成员变量(属性或者方法)
查看>>
HDU 5656 CA Loves GCD 01背包+gcd
查看>>
关于Servlet周期问题
查看>>
diff文件制作
查看>>
js正则表达式验证身份证号和密码
查看>>
Windows下MySQL的my.ini文件字符集测试(二)
查看>>
Linux 命令大全
查看>>
[Database] Oracle 中的where 可以后接group by
查看>>
AsyncTask和Handler
查看>>
通过HttpClient调用服务
查看>>
请求不携带cookie问题
查看>>
AOSP、AOKP、CM的区别
查看>>
ES6 类
查看>>
如何将qlv格式的腾讯视频转换为mp4格式
查看>>
leetcode 416. Partition Equal Subset Sum
查看>>
leetcode 695. Max Area of Island
查看>>
Linux命令之乐--telnet
查看>>
Jupyter Notebook 快速入门
查看>>
CompositeTransform 类11111111
查看>>
c#的DateTime.Now函数详解
查看>>