유돌이

calendar

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

Notice

2009. 1. 10. 13:41 C/C++/MFC

#include <stdio.h>
struct node{
 int i;
 struct node* link;
}*p;
int insert(int a);
int printe();
int delet(int c);

void main()
{
 p=NULL;
 insert(3);
 insert(4);
 insert(5);
 delet(4);
 printe(p);
}
int insert(int a)
{
 struct node *temp;
 temp=(struct node *)malloc(sizeof(temp));
 temp->i=a;
 temp->link=p;
 p=temp;
 return 0;
}

int printe()
{
 struct node *t;
 t=p;
 while(t!=NULL){
   printf("%d \n", t->i);
   t=t->link;
 }
 return 0;
}

int delet(int c)
{
 struct node *m;
 struct node *n; 

 m=p;
 if(m->i == c)
 {
  p=p->link;
 } 
 else{
  n=m;
  m=n->link;
  while(m!=NULL){
   if(m->i==c){
    n->link=m->link;
    break;
   }
   else{
    n=m;
    m=m->link;
   }
  }
 
  
 }
 return 0;
}


'C/C++/MFC' 카테고리의 다른 글

DoModal() 이란??  (0) 2009.01.14
C_STR() 이란??  (0) 2009.01.10
가상 상속  (0) 2009.01.10
" call by value " 와 " call by reference " 의 차이점  (0) 2009.01.10
API 종료 방법  (0) 2009.01.10
posted by 유돌이