#include
#include
#include
#include
#include
int Student=0;
int N;
int Mark[100];
int Mark1[100];
struct student *Head;
struct student
{
char Name[20];
char Snum[20];
char Sex[4];
};
typedef struct node
{
char name[20];
char snum[20];
char sex[4];
struct node *pnext;
}node,*pnode;
struct student *GetData();
pnode create_list();
void traverse_list(pnode phead);
int length_list(pnode phead);
void sort_list(pnode phead);//
void inverse_list(pnode phead);
void delete_list(pnode phead);
int insert_list(pnode phead);
void main()
{
srand(time(NULL));
pnode head=NULL;
head=create_list();
printf("\n");
traverse_list(head);
sort_list(head);
printf("1.按照学号大小正排序后:\n");
traverse_list(head);
int pos;
pos=rand()%N+1;////
printf("2.系统随机删除的同学第%d个同学\n\n删除后按学号反序输出",pos);///
inverse_list(head);
traverse_list(head);
printf("3.系统已从剩余学生中抽取了一位\n\n");
printf("插入该生序号为%d\n\n",insert_list(head));
traverse_list(head);
}
pnode create_list()
{
int m=0,i,j,r;
Head=GetData();
printf("\n");
for(i=0;i Mark[i]=i;
for(i=0;i {
r=rand()%(Student-i);
Mark1[m++]=Mark[r];
for(j=r;j Mark[j]=Mark[j+1];
}
m=0;
pnode head=(pnode)malloc(sizeof(node));
pnode tail=head;
tail->pnext=NULL;
printf("请输入你想抽取学生人数N:");
scanf("%d",&N);
for(i=0;i {
pnode pnew=(pnode)malloc(sizeof(node));
strcpy(pnew->name,Head[Mark1[m]].Name);
strcpy(pnew->snum,Head[Mark1[m++]].Snum);
strcpy(pnew->sex,Head[Mark1[m++]].Sex);
tail->pnext=pnew;
pnew->pnext=NULL;
tail=pnew;
}
return head;
}
void traverse_list(pnode phead)
{
pnode p=phead->pnext;
printf("学生信息为:\n\n");
while(p!=NULL)
{
printf("\t%s\t%s\t%s\t",p->name,p->snum,p->sex);
p=p->pnext;
}
printf("\n");
}
int length_list(pnode phead)
{
int len=0;
pnode p=phead->pnext;
while(p!=NULL)
{
len++;
p=p->pnext;
}
return len;
}
void sort_list(pnode phead)
{
int i,j,len;
char name[20],num[20],sex[4];///
pnode q;
len=length_list(phead);
for(i=0;i {
for(j=0,q=phead->pnext;j,len-1-i;q=q->pnext,j++)
if(strcmp(q->snum,q->pnext->snum)>0)
{
strcpy(name,q->name);
strcpy(q->name,q->pnext->name);
strcpy(q->pnext->name,name);
strcpy(num,q->snum);
strcpy(q->snum,q->pnext->snum);
strcpy(q->pnext->snum,num);
strcpy(sex,q->sex);
strcpy(q->sex,q->pnext->sex);
strcpy(q->pnext->sex,sex);
}
}
}
void delete_list(pnode phead,int pos)
{
pnode p=phead;
int i=0;
while(p->pnext!=NULL&&i {
p=p->pnext;
i++;
}
pnode q=p->pnext;
p->pnext=p->pnext->pnext;
free(q);
q=NULL;
}
int insert_list(pnode phead)
{
int m=rand()%(Student-N)+N;
pnode p=phead;
pnode q=(pnode)malloc(sizeof(node));
strcpy(q->name,Head[Mark1[m]].Name);
strcpy(q->snum,Head[Mark1[m]].Snum);
strcpy(q->sex,Head[Mark1[m]].Sex);
q->pnext=p->pnext;
p->pnext=q;///
inverse_list(phead);
pnode pt=phead;
int location=0;
pnode s=(pnode)malloc(sizeof(node));
strcpy(s->snum,Head[Mark1[m]].Snum);
while(pt!=NULL)
{
pt=pt->pnext;
location++;
if(strcmp(s->snum,pt->snum)==0)
break;
}
return location;
}
struct student *GetData()
{
int i;
struct student students[100];
FILE *fp;
fp=fopen("a.txt","r");
printf("导入学生数据:\n\n");
for(i=0;!feof(fp);i++)
{
fscanf(fp,"%s%s%s",students[i].Name,students[i].Snum,students[i].Sex);
printf("\t%s\t%s\t%s\t\n",students[i].Name,students[i].Snum,students[i].Sex);
}////
Student=i;
return students;
}
error LNK2001: unresolved external symbol "void __cdecl inverse_list(struct node *)" (?inverse_list@@YAXPAUnode@@@Z) Debug/34343434.exe : fatal error LNK1120: 1 unresolved externals
inverse_list函数申明了但未实现
你这是抄过来的吧,函数没实现就去实现呗