game2.cpp
来自「这是个数据结构课程设计!功能强大。不信你下载下来看一看!」· C++ 代码 · 共 56 行
CPP
56 行
#include "cpp3.h"
void Joseph(SeqList c[],int length)
{
int m;
cout<<"please input first interval m(m<=20)";
cin>>m;
while(m>20)
{
cout<<"It's too large.please input another number:\n";
cin>>m;
}
cout<<"please input code:"<<endl;
getchar();
char s[10];
for(int i=0;i<length;i++)
{
cout<<"第"<<i+1<<"个人的名字:";
gets(s);
c[i].SetName(s);
}
i=-1;
int j,k;
for (k=1;k<=length;k++)
{
j=0;
while(j<m)
{
i++;
if(i==length)
i=0;
if(c[i].GetNum()!=0)
j++;
}
if(k==length)
break;
c[i].DispName();
cout<<",";
c[i].SetNum(0);
}
c[i].DispName();
cout<<endl;
}
void game1()
{
const int n=30;
int length=0;
cout<<"please input the number of people:";
cin>>length;
SeqList c[n];
for(int i=0;i<length;i++)
{
c[i].SetNum(i+1);
c[i].SetName(" ");
}
Joseph(c,length);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?