#include<stdio.h>
#include<stdio.h>
struct node {
int data;
struct node *link;
};
void insert();
main()
{
struct node *t,*h;
int k;
scanf("%d",&k);
while(k!=0)
{
insert(h,t,k);
scanf("%d",&k);
}
}
-
void insert(struct node *head,struct node *tail,int k)
{
struct node *p,*pre,*ppre;
p=(struct node *)malloc(sizeof(struct node));
p->data=k;
if(tail==null)
{
head=tail=p;
tail->link=null;
return(o);
}
pre=head;
while(pre->data>k)
{
ppre=pre;
pre=pre->link;
}
if(ppre==null)
{
<--맨앞에 , insert; -->
}
else if(pre==null)
{
<-- 맨뒤에 ) -->
}
else
{
<-- 가운데 -->
return(0);
}
}
이런 소스인데.. 뒷부분에 앞,뒤,가운데를 채워넣으랍니다.
구조체쪽엔 아직 무지해서.. 어떻게 건들질 못하겠군요.;
글구.. insert 문은 어떨때 사용하나요? 끼어넣는다는건 알겠는데 정확한 사용법을잘..;;
|