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

你可能感兴趣的文章
笛卡尔树
查看>>
Sqoop 工具使用
查看>>
hadoop生态--Zookeeper
查看>>
Class.forName(String driverClassName)加载JDBC驱动程序时,底层都做了些什么???...
查看>>
2.安装中国版本的firefox
查看>>
mysql导出CSV格式的文件
查看>>
NetWaiting 完美卸载方法
查看>>
SpringBoot集成MybatisPlus
查看>>
人生规划和GTD——“知”、“得”与“合”
查看>>
Linux学习笔记(13)-进程通信|命名管道
查看>>
Ubuntu 目录结构
查看>>
Linux笔记一
查看>>
[ 51Nod 1327 ] 棋盘游戏
查看>>
Windows 10 内置管理员无法打开Metro应用方法
查看>>
MySql按每日、每周、每月分组统计数据
查看>>
[转]spring4.x注解概述
查看>>
工作两周总结
查看>>
十天学会易语言图解教程+快速入门
查看>>
安卓第一天
查看>>
11.26号
查看>>