linked list 자료구조에 관한 Report 같으므로 패쑤..
먼저 linked list 를 공부하셔서 개념을 잡으시고, 부수적으로 struct 키워드에 대한 이해를..
그리고 node라는 명명에 대한 이해를 하시는게 해결의 실마리입니다.
숙제는 스스로.. 막힐 때는 도움을..
스터디맨 님이 쓰신 글 :
: #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 문은 어떨때 사용하나요? 끼어넣는다는건 알겠는데 정확한 사용법을잘..;;
|