炒面酸甜的做法大全:error C2601: 'main' : local function definitions are illegal

来源:百度文库 编辑:中科新闻网 时间:2024/05/06 05:23:20
#include<stdio.h>
#include<stdlib.h>

struct student
{
char name[10];
float score;
struct student *next;
};
struct student *insert (struct student *head)
{
struct student *p,*pnew,*pold;
pnew=(struct student *)malloc (sizeof(struct student));
scanf("%s%f",pnew->name,&pnew->score);
p=head;
if(pnew->score>head->score)
{
pnew->next=head;head=pnew;
}
else
{
while(p!=NULL&&pnew->score<p->score)
{
pold=p;p=p->next;
}
return head;
}

void print (struct student *head1)
{
struct student *p=head1;
while(p!=NULL)
{
printf("%s %.f\n",p->name,p->score);
p=p->next;
}
}

struct student *pdelete(struct student *head2,char names[10])
{
struct student *p=head2,*pold=head2;
char tt[10]=names;

if(head2==NULL) return head2;
if(head2->name==tt)
{
head2=head2->next;free(p);
}
else

while(p!=NULL)
{
if(p->name==tt)
{
pold->next=p->next; free(p);

break;}
else{pold=p;p=p->next;}
}
return head2;
}
void main()
{

struct student *head3;
int menu;
char tt[10];
head3=(struct student *)malloc(sizeof(struct student));

while(1)
{
printf("Enter (1) to Add a Student to Class List\n"
" (2) to Delete a Student from Class List\n"
" (3) to show Class List\n"
" (4) to Edit marks of a Student\n"
" (5) to Quit\n");
fflush(stdout);

scanf("%d",&menu) ;

if (menu < 1 || menu > 5)
{
printf("incorrect selection");
continue;
}

else if (menu == 1)
head3=insert(head3);
else if (menu == 2)
{
printf("输入学生NAME\n");
tt=gets();

head=pdelete(head,tt);
}
else if (menu == 3)
print(head3);

else break;

}

}
高手帮忙啊!
都是head
没有head1等

insert那个函数定义少了个结束 }