作业帮 > 综合 > 作业

每一步都说的什么,#include using namespace std; const int people = 17

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/09 02:56:50
每一步都说的什么,
#include
using namespace std;
const int people = 17;
struct outt
{
outt *next;
bool go;
int num;
};
int main( )
{
outt *p,*head;
int i,n = 0,t = 0;
head = new outt;
head->go = true;
head->num = 1;
p = head;
for ( i = 1; i < people; i++ )
{
outt *s = new outt;
p->next = s;
s->go = true;
s->num = i + 1;
p = s;
}
p->next = head;
p = head;
while ( n = people - 1 )
{
t++;
if ( t % 3 == 0 )
{
if ( p->go )
{
n++;
p->go = false;
}
else
t--;
}
p = p->next;
}
p = head;
while ( p->go )
{
p = p->next;
}
cout num;
return 0;
}
#include
using namespace std;
const int people = 17;
struct outt //定义一个结构
{
outt *next; //定义一个数据成员(指针)
bool go; //逻辑型变量
int num; //整型变量
};
int main( )
{
outt *p,*head;
int i,n = 0,t = 0;
head = new outt;//申请动态空间
head->go = true; //第一个节点为真
head->num = 1; //...
p = head; //在表头插如结点
for ( i = 1; i < people; i++ ) //循环
{
outt *s = new outt; //申请动态空间
p->next = s;
s->go = true;
s->num = i + 1;
p = s;
}
p->next = head;
p = head;
while ( n != people - 1 )
{
t++;
if ( t % 3 == 0 )
{
if ( p->go )
{
n++;
p->go = false;
}
else
t--;
}
p = p->next;
}
p = head;
while ( !p->go )
{
p = p->next;
}
cout num;
return 0;
}
太多了.