用c语言描述数据结构编写一个能输出学生学号,年龄 性别的源代码?还有顺序表的删除与插入源代码

编写一个能输出学生学号,年龄 性别的源代码?还有顺序表的删除与插入源代码

1、结构体
struct std{
int num;
int age;
char sex;
};
2、顺序表
#include<stdio.h>
#include<stdlib.h>
#define maxsize 1024
typedef int datatype;

typedef struct{
datatype data[maxsize];
int last;
}sequenlist;

sequenlist* InitList()
{
sequenlist *L=(sequenlist*)malloc(sizeof(sequenlist));
L->last=0;
return L;
}

int InsertList(sequenlist* L,datatype x,int i)
{
int j;
if(L->last>=maxsize-1)
{
printf("List Overflow!\n");
return 0;
}
else if(i<1||i>L->last+1)
{
printf("Error Insert Place!\n");
return 0;
}
else
{
for(j=L->last;j>=i;--j)
L->data[j+1]=L->data[j];
L->data[i]=x;
++L->last;
return 1;
}
}

int DeleteList(sequenlist* L,int i)
{
int j;
if((i<1)||(i>L->last))
{
printf("Error Delete Place!\n");
return 0;
}
else
{
for(j=i;j<L->last;++j)
L->data[j]=L->data[j+1];
--L->last;
return 1;
}
}

int PrintList(sequenlist* L)
{
int i;
if(L->last<0||L->last>maxsize-1)
{
printf("Error List!\n");
return 0;
}
else if(L->last==0)
{
printf("Empty List!\n");
return 0;
}
else
{
printf("/****Now Printing List...****/\n");
for(i=1;i<=L->last;++i)
printf("data(%d)\t%d\n",i,L->data[i]);
printf("/****Printing Ended!****/\n");
return 1;
}
}

int LengthList(sequenlist* L)
{
return L->last;
}

int LocateList(sequenlist* L,datatype x)
{
int i=1;
for(;i<=L->last;++i)
if(L->data[i]==x) return i;
return 0;
}

void DelNodeList(sequenlist* L,datatype x)
{
int i;
i=LocateList(L,x);
while(i)
{
if(DeleteList(L,i)==0) break;
i=LocateList(L,x);
}
}追问

我能加你QQ吗?

追答

736900871

温馨提示:答案为网友推荐,仅供参考
相似回答