让人郁闷的函数 --为什么只能做主函数却不 能做子函数呢?
#include"stdio.h"
#include"stdlib.h"
struct elem
{
int qu;
char elem;
struct elem *next,*left,*right;
};
struct elem *creattree()
{
struct elem *head,*last,*this,*new;
char c;
int size;
head->next=last;
last->next=0;
size=sizeof(struct elem);
printf("please input char such as A ,then input num such as 8 :\n");
loop:
new=(struct elem *)malloc(size);
scanf("%c %d",&new->elem,&new->qu);
c=getchar();
last->qu=new->qu;
for(this=head;this->next!=0;this=this->next)
{
if(new->qu<=this->next->qu)
{
new->next=this->next;
this->next=new;
break;
}
}
switch(c)
{
case '\n':goto loop;
defult :last=0;break;
}
return head;
}
main()
{
struct elem *head,*this;
this=head->next;
while(this->next!=0)
{
printf("%d %c\t",this->qu,this->elem);
this=this->next;
}
}