📄 2.cpp
字号:
#include <stdlib.h>
#include<iostream.h>
typedef struct node
{
int num;
int sec;
struct node *next;
}*Node;
Node Creatlist(int n)
{
Node L,p1,p2;
int i;
L=p2=(Node*)malloc(sizeof(Node));
L->num=1;
printf("\nplease enter the man.1\'s sec:");
scanf("%d",&L->sec);
printf("\n");
for(i=2;i<=n;i++)
{
p1=(Node*)malloc(sizeof(Node));
p1->num=i;
printf("Enter the man.%d\'s sec:",i);
scanf("%d",&p1->sec);
printf("\n");
p2->next=p1;
p2=p1;
}
p2->next=L;
return(L);
}
void dellist(Node p,int n,int m)
{
Node pl;
int i=1;
while(n!=0)
{
while(i<m)
{
pl=p;
p=p->next;
i++;
}
printf("\nThe Out Man is %d \n",p->num);
m=p->sec;
pl->next=p->next;
p=pl->next;
i=1;
n--;
}
}
main()
{
Node p=NULL;
int s,n,m;
printf("\nEnter the number of the man :");
scanf("%d",&n);
printf("Enter the first sec:");
scanf("%d",&m);
p=Creatlist(n);
for(s=0;s<n;s++)
{p=p->next;
}
dellist(p,n,m);
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -