主题:[讨论]猴子出队列的问题
大家帮忙看一下啊,这个程序我想了半天不知道什么地方有错误,
#include <stdio.h>
struct Mnokey
{
int no;
struct Monkey *next;
};
main()
{
Monkey *link,*monkey,*lastMonkey;
int totalMonkey,stride,count;
printf("please input the total:\n");
scanf("%d",&totalMonkey);
printf("please input the digital of outsquee: \n");
scanf("%d",&stride);
//create link
link=NULL;
for(i=0;i<totalMonkey;i++)
{
monkey=new Monkey();
monkey->no=i+1;
if(link==NULL)
link=lastMonkey=monkey;
else
{
lastMonkey->next=monkey;
lastMonkey=monkey;
}
}
lastMonkey->next=link;
count=1;
printf("the list of out is :");
while(link!=NULL)
{
if(link->next==link)
printf("just hava only one :%4d",link->no);
delete link;
break;
}
if(count==stride-1)
{
monkey=link->next;
link->next=monkey->next;
printf("%4d",monkey->no);
delete monkey;
count=0;
}
link=link->next;
count++;
}
、麻烦帮忙看一下啊!!!!!!!!!!!!!!111
#include <stdio.h>
struct Mnokey
{
int no;
struct Monkey *next;
};
main()
{
Monkey *link,*monkey,*lastMonkey;
int totalMonkey,stride,count;
printf("please input the total:\n");
scanf("%d",&totalMonkey);
printf("please input the digital of outsquee: \n");
scanf("%d",&stride);
//create link
link=NULL;
for(i=0;i<totalMonkey;i++)
{
monkey=new Monkey();
monkey->no=i+1;
if(link==NULL)
link=lastMonkey=monkey;
else
{
lastMonkey->next=monkey;
lastMonkey=monkey;
}
}
lastMonkey->next=link;
count=1;
printf("the list of out is :");
while(link!=NULL)
{
if(link->next==link)
printf("just hava only one :%4d",link->no);
delete link;
break;
}
if(count==stride-1)
{
monkey=link->next;
link->next=monkey->next;
printf("%4d",monkey->no);
delete monkey;
count=0;
}
link=link->next;
count++;
}
、麻烦帮忙看一下啊!!!!!!!!!!!!!!111