달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

오전) 아트메가 각 버스별 비트숫자가 의미하는 명령어

 

오후) 링크드 리스트

 

핵심 : 중간삽입은...

삽입할 구조체가 stpnew라 카므는..

조건 만족시에,

stpfront->next=stpnew;

stpnew-next=rear;

즉 stpnew가 앞 놈의 next고, 자신의 next는 뒷 놈으로 넣는다.

 

 

 

 

조건 식은... stpnew->data가 stprear->데이타 보다 작다는 것.

 

아, 열 핵심스러운 설명이네요. 감탄감탄+_+;

 

 

 

위 코드는 아래와 같습니다.

 

void Node_Insert(Node * head,char Cdata)
{
 Node* stpfront=head;
 Node* stprear=head;
 
 Node* stpnew=malloc(sizeof(Node));
 stpnew->data=Cdata;
 stpnew->next=0;
 

 while(stprear->next!=0)
 {
  stpfront=stprear;
  stprear=stprear->next;
  if(stprear->data>stpnew->data)
  {
   stpfront->next=stpnew;
   stpnew->next=stprear;
   
   break;
  }
 }

}

 

이상으로,

링크드리스트 중간삽입에 대하여 알아보았습니다.

 

 

Posted by C언어 보이
|