每一步都说的什么,#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 < p
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 15:38:07
每一步都说的什么,#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 < p
每一步都说的什么,
#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 < p
#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;
}
太多了.