?? cpp1.cpp
字號:
#include<iostream.h>
#include<iomanip.h>
struct jose{
int code;
int data;
jose *next;
};
void main(){
int num=0;
int interval=0;
while(num==0){
cout<<"請輸入游戲人數!"<<endl;
cin>>num;
if(num==0)
cout<<"輸入人數無效!"<<endl;
}
while(interval==0){
cout<<"請輸入初始密碼!"<<endl;
cin>>interval;
if(interval==0)
cout<<"輸入密碼無效!"<<endl;
}
jose *head,* S1,* S2;
head=new jose;
S1=head;
for(int i=1;i<num;i++)
{
S1->code=0;
S1->data=i;
while(S1->code==0)
{
cout<<"請輸入第"<<i<<"個密碼"<<endl;
cin>>S1->code;
if(S1->code==0)
cout<<"輸入有誤!"<<endl;
}
S2=new jose;
S1->next=S2;
S1=S2;
}
S1->data=i;
S1->code=0;
while(S1->code==0)
{
cout<<"請輸入第"<<i<<"個密碼"<<endl;
cin>>S1->code;
if(S1->code==0)
cout<<"輸入無效"<<endl;
}
S1->next=head;
jose * p,* pivot;
p=head;
cout<<"出列順序為:"<<endl;
while(p->next!=p){
for(int j=1;j<interval;j++)
{
pivot=p;
p=pivot->next;
}
cout<<p->data<<endl;
interval=p->code;
pivot->next=p->next;
p=pivot->next;
}
cout<<p->data<<endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -