| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我晕倒,程序输入大于10 的时候就卡死#include <iostream>
using namespace std;
typedef struct node{
int number;
bool exit;
struct node* next;
}node,*pnode;
int main(){
node head;
head.number=1;
head.exit=true;
head.next=NULL;
node* p=NULL;
p=&head;
node* q=NULL;
int k;
int i;
int m;
int count;
while(cin>>k){
if (k==0)return 0;
for (i=0;i<2*k-1;i++)
{
q=new node;
q->number=i+2;
q->exit=true;
q->next=NULL;
p->next=q;
p=q;
}
p->next=&head;
for (m=1;m<2504884;m++)//0x7fffffff
{
for (i=0;i<2*k;i++)
{
p->exit=true;
p=p->next;
}
p=&head;
i=1;
count=0;
while(1){
if (i <= m)
{
if (p->exit==true)
{
if (i==m)
{
int fsdfsd=p->number;
if (p->number <= k)break;
else
{
count++;
p->exit=false;
if (count==k)
{
goto showm;
}
}
} //if(i==m)
p=p->next;
i++;
}
else
{
p=p->next;
}
}
else
{
i=1;
}
}//while(1)
}//m=0;m<10000;m++
showm:
cout<<m<<endl;
p=&head;
for (i=0;i<2*k;i++)
{
p->number=0;
p->exit=false;
p=p->next;
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator