91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 0.4M
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-02
  • 語言: 其他
  • 標簽: 其他??

資源簡介

ysfGame.zip

資源截圖

代碼片段和文件信息

#include
using?namespace?std;

class?Node?????????//創建雙向循環鏈表的結點類
{
??????friend?class?Doublelist;????//作為友元類
??????friend?void?DoubleJoseph();??//作為友元函數來調用
??????
??????public:
?????????????Node();
?????????????int?data;
?????????????Node?*prior;
?????????????Node?*next;
???????private:
};

class?Doublelist?????//雙向循環鏈表類
{
??????friend?void?DoubleJoseph();????//作為友元函數來調用
??????public:
?????????????void?Creatlist(Doublelist?&L);???//雙向循環鏈表
?????????????int?getLength(Doublelist?&L);????//用于獲取雙向鏈表的長度
?????????????Doublelist();
??????private:
??????????????Node?*Head;
};



Node::Node()?????//Doublelist類的構造函數初始化結點數據
{
????????????data?=?0;
????????????prior?=?NULL;
????????????next?=?NULL;
}



Doublelist::Doublelist()????//Doublelist類的構造函數初始化鏈表數據
{
????????????????????????Head?=?NULL;
}




void?Doublelist::Creatlist(Doublelist?&L)???//建立雙向循環鏈表
{
?????cout?<?????int?n;
?????cin?>>?n;
?????Node?*p*s;
?????for(int?i=1;i<=n;i++)
?????{
?????????????p=new?Node;?????//構造頭結點
?????????????p->data=i;
?????????????p->next=NULL;??
?????????????if(i==1)
?????????????{
??????????????????L.Head=p;?
??????????????????p->prior=NULL;
??????????????????s=L.Head;
?????????????}
?????????????else
?????????????{
??????????????????s->next=p;
??????????????????p->prior=s;
??????????????????s=s->next;
?????????????}??
?????}
?????s->next?=?L.Head;
?????L.Head->prior?=?p;
}



int?Doublelist::getLength(Doublelist?&L)???//獲取雙向鏈表的長度
{
????Node?*p?=?L.Head;
????int?count?=?0;
????while(p->next?!=?L.Head)
????{
??????????????????count++;
??????????????????p?=?p->next;
????}
????count++;
????return?count;
}



void?DoubleJoseph()???//實現約瑟夫雙向生死游戲
{
?????Doublelist?L;???//定義鏈表
?????L.Creatlist(L);???//建立鏈表
?Node?*p*q*r;??//定義指針
?????p?=?L.Head;????//定義頭結點

?????cout?<?????int?s;
?????cin?>>?s;
?????cout?<?????int?m;
?????cin?>>?m;??
?????cout?<?????int?w;
?????cin?>>?w;
?????cout?<?????int?k;
?????cin?>>?k;
?????cout?< ?
?????int?t?=?1;????//初始定義t值
?????while(?k?????{
??????????if(t%2)???//判斷正向逆向
??????????{?
???????????????for(int?j=0;?j ?{
?????????????????????????q=p;
?????????????????????????p=p->next;
?????????????????}
???????????????if(p?==?L.Head)?????//元素定位出列?
?????????????????{
?????????????????????????r=p;
?????????????????????????L.Head?=?p->next;??//指向下一元素結點
?????????????????????????q->next?=?p->next;?????????//依次更換元素結點
?????????????????????????p->next->prior?=?q;
?????????????????????????p?=?p->next;
?????????????????}?????????????
??????????????else???
??{
?????????????????????r?=?p;
?????????????????????q->next?=?p->next;
?????????????????????p->next->prior?=?q;

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????5121??2017-06-30?21:08??ysf\ysfg.cpp
?????文件??????477930??2019-01-08?19:24??ysf\報告.docx

評論

共有 條評論