C语言,指针、结构体和链表方面的简单的程序,帮我改错就行,请注释和修正,,发源代码给我,谢谢
LIBCD.lib(crt0.obj):errorLNK2001:unresolvedexternalsymbol_mainDebug/pro8_6666.exe:fat...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/pro8_6666.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
pro8_6666.exe - 1 error(s), 0 warning(s)
#include<malloc.h>
#include<stdio.h>
#include<string.h>
struct Student{
int Student_ID;
char name[12];
int score;
struct Student *next;
};
void sort(struct Student *p)
{
int i,j;
struct Student temp;
for(i=0;i<2;i++)//bubble
{
for(j=i+1;j<2;j++)
{
if(p[j].score<p[j+1].score)
{
temp=p[j];
p[j]=p[j+1];
p[j+1]=temp;
}
}
}
}
struct Student * score_list()
{
int i,n;
struct Student *head=NULL,*p1,*p2=NULL;
void sort(struct Student *p);
printf("请输入学生数量n:");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
if((p1=malloc(sizeof(struct Student)))==NULL)
{
printf("no\n");
exit(0);
}
p1->next=NULL;
printf("请输入第%d位学生的学号、姓名、分数(以空格隔开,以回车结束):",i);
scanf("%d%s%d",&p1->Student_ID,p1->name,&p1->score);
if(i==1)head=p1;else p2->next=p1;
p2=p1;
}
sort(head);
p1=head;
for(i=0;i<n;i++)printf("%-6d%-9s%-6d\n",p1->Student_ID,p1->name,p1->score);
return head;
}
void sort(struct Student *p)/* *p就是*head */
{
struct Student *pp,*p0,*p1,*p2,*p3;
if(p->next->next==NULL)//无比较对象
exit(0);
//在中间的交换
while(p=p->next)
{
p0=p; //从第一个有效的开始
p1=p0->next;
p2=p1->next;
p3=p2->next;
pp=p->next;
while(pp)
{
if(p1->score<p1->next->score)
{
p1->next=p3;
p2->next=p1;
p0->next=p2;
}
pp=pp->next;
}
}
} 展开
Debug/pro8_6666.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
pro8_6666.exe - 1 error(s), 0 warning(s)
#include<malloc.h>
#include<stdio.h>
#include<string.h>
struct Student{
int Student_ID;
char name[12];
int score;
struct Student *next;
};
void sort(struct Student *p)
{
int i,j;
struct Student temp;
for(i=0;i<2;i++)//bubble
{
for(j=i+1;j<2;j++)
{
if(p[j].score<p[j+1].score)
{
temp=p[j];
p[j]=p[j+1];
p[j+1]=temp;
}
}
}
}
struct Student * score_list()
{
int i,n;
struct Student *head=NULL,*p1,*p2=NULL;
void sort(struct Student *p);
printf("请输入学生数量n:");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
if((p1=malloc(sizeof(struct Student)))==NULL)
{
printf("no\n");
exit(0);
}
p1->next=NULL;
printf("请输入第%d位学生的学号、姓名、分数(以空格隔开,以回车结束):",i);
scanf("%d%s%d",&p1->Student_ID,p1->name,&p1->score);
if(i==1)head=p1;else p2->next=p1;
p2=p1;
}
sort(head);
p1=head;
for(i=0;i<n;i++)printf("%-6d%-9s%-6d\n",p1->Student_ID,p1->name,p1->score);
return head;
}
void sort(struct Student *p)/* *p就是*head */
{
struct Student *pp,*p0,*p1,*p2,*p3;
if(p->next->next==NULL)//无比较对象
exit(0);
//在中间的交换
while(p=p->next)
{
p0=p; //从第一个有效的开始
p1=p0->next;
p2=p1->next;
p3=p2->next;
pp=p->next;
while(pp)
{
if(p1->score<p1->next->score)
{
p1->next=p3;
p2->next=p1;
p0->next=p2;
}
pp=pp->next;
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询