⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 joseph.bak

📁 1. 本程序中
💻 BAK
字号:
#include"malloc.h"
#include"stdio.h"
#define MAX 100
#define ERROR 0
typedef struct LNode
  {
  int num;
int code;
  struct LNode *next;
  }LNode;
LNode *L,*p,*newspace,*q;
int str[MAX];
CreatList_L(int a);
ListDelete_L(int a,int b);
main()
{
int m,n,i;
printf("Enter the first code(m):");
scanf("%d",&m);
printf("\nEnter the people number(n):");
scanf("%d",&n);
printf("\n");
CreatList_L(n);
if(L!=NULL)
  ListDelete_L(n,m);
else
  printf("No List!\n");
for(i=0;i<n;i++)
printf("%-3d",str[i]);
printf("\n");
}
CreatList_L(int a)
{
int i=1;
int codestr[50];
newspace=(LNode*)malloc(sizeof(LNode));
if(!newspace)
  return ERROR;
if(L==NULL)
L=newspace;
p=L;
while(--a!=0)
  {
  p->num=i;
  printf("Enter the %d code:",i);
  scanf("%d",&codestr[i]);
  p->code=codestr[i];
  newspace=(LNode*)malloc(sizeof(LNode));
  p->next=newspace;
  p=newspace;
  i++;
  }
p->num=i;
printf("Enter the %d code:",i);
scanf("%d",&codestr[i]);
p->code=codestr[i];
p->next=L;
}
ListDelete_L(int a,int b) 
{
int i, j=0;
while(--a!=0)
  {
  for(i=1;i<=b;i++)
    {
    q=p; p=p->next;
    }
  b=p->code;
  str[j]=p->num;
  q->next=p->next;
  free(p);
  p=q;
  j++;
  }
str[j]=p->next->num;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -