求大佬帮忙注释一下,初学小白,什么都看不懂
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define OK 1
#define ERROR -1
#define MaxSize 100
typedef int status;
typedef struct stu{
char name[20];
int age;
int no;
}Stu;
typedef struct sqlist{
Stu *Elem;
int length;
}Sqlist;
status Init_List(Sqlist *L)
{
L->Elem=(Stu *)malloc(MaxSize*sizeof(Stu));
if(!L->Elem)
{
printf("Allocation Error!\n");
return ERROR;
}
L->length=0;
return OK;
}
status Insert_List(Sqlist *L,int pos,Stu *s)
{
int k;
if(pos<1 || pos>L->length+1)
return ERROR;
for(k=L->length-1;k>=pos-1;k--)
L->Elem[k+1]=L->Elem[k];
printf("Input information of the new student (name age number):\n");
scanf("%s %d %d",s->name,&s->age,&s->no);
L->Elem[pos-1]=*s;
L->length++;
return OK;
}
status Del_List(Sqlist *L,char *name)
{
int i;
if(L->length==0)
return ERROR;
for(i=0;i<L->length;i++)
if(strcmp(name,L->Elem[i].name)==0)
break;
if(i==L->length)
{
printf("Can not find %s.\n",name);
return ERROR;
}
while(i<L->length-1)
{
L->Elem[i]=L->Elem[i+1];
i++;
}
L->length--;
return OK;
}
void Output(Sqlist *L)
{
int i;
printf("The elements in the list:\n");
for(i=0;i<L->length;i++)
printf("student %d: %20s %3d %8d\n",i+1,L->Elem[i].name,L->Elem[i].age,\
L->Elem[i].no);
printf("\n");
}
int main()
{
Sqlist L;
Stu s;
int i,n;
char name[20];
Init_List(&L);
printf("Input the number of the students.\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
Insert_List(&L,i,&s);
Output(&L);
printf("Input the position of the new student.\n");
scanf("%d",&n);
Insert_List(&L,n,&s);
Output(&L);
printf("Input the name of the student to be deleted.\n");
scanf("%s",name);
Del_List(&L,name);
Output(&L);
return OK;
}