''다시 부활'' [[TableOfContents]] = ì°¸ì—¬ìž ëª…ë‹¨ = || 함장 || 장용운 || 11학번 || ì§€ê° || ||<|7> ì„ ì› || 천준현 ||<|7> 15학번 || ê²°ì„ || || ìµœì§€í˜ || ì¶œì„ || || ë°•ì¸ì„œ || ì¶œì„ || || ì´ì •재 || ê³ í–¥ || || ì´ì›ì¤€ || ì¶œì„ || || 조종현 || ì¶œì„ || || 남헌 || 숙면 || = 수업 = == ì§„í–‰ == 1. 장소 : 6층 PC실 2. 시간 : 14시 30ë¶„~ == ë‚´ìš© == ~~기억 ì†ì—서 사ë¼ì§„~~ '''기존 ë‚´ìš© 복습''' * 구조체 * ë™ì 메모리 í• ë‹¹ * ì—°ê²° 리스트 '''수심 1000m. 스íƒ''' * ìŠ¤íƒ ë§Œë“¤ê¸° * ë¬¸ì œí•´ê²° = 코드 = == ì˜ˆì œ1 == {{{ #include <stdio.h> #include <malloc.h> typedef struct _node{ int value; struct _node * next; } node; void freeAll(node*); int main(void) { node* head; head = (node*)malloc(sizeof(node)); node* temp = head; for (int i = 0; i < 50; i++) { temp->next = (node*)malloc(sizeof node); temp->value = i; temp = temp->next; } temp->next = NULL; temp->value = 50; freeAll(head); return 0; } void freeAll(node* hd) { node* t; while (hd != NULL) { t = hd->next; printf("%d ", hd->value); free(hd); hd = t; } } }}} = ìˆ™ì œ = 1. 복습하기 2. 복습하기 3. 복습하기 ---- = ìˆ™ì œ ì œì¶œ = == 천준현 == == ìµœì§€í˜ == == ë°•ì¸ì„œ == * ì—°ê²° 리스트 {{{ #include <stdio.h> #include <stdlib.h> typedef struct node{ int value; struct node * next; }node; void freeall(node * hd) { node * t=hd->next; while(hd!=NULL) { t=hd->next; printf("%d\n",hd->value); free(hd); hd=t; } } int main() { node * head; node * temp; int i; head = (node *)malloc(sizeof(node)); head->value=0; head->next=(node *)malloc(sizeof(node)); temp=head; for(i=0;i<50;i++) { temp->next=(node *)malloc(sizeof(node)); temp->value=i; temp=temp->next; } temp->next=NULL; temp->value=50; freeall(head); return 0; } }}} * ìŠ¤íƒ {{{ #include <stdio.h> #include <stdlib.h> typedef struct node{ int val; struct node* next; }node; void push(node **, int); int pop(node **); int main() { node * head=NULL; push(&head,3); printf("%d ",pop(&head)); return 0; } void push(node ** target, int val) { node * newnode=(node *)malloc(sizeof(node)); newnode->val=val; newnode->next=*target; *target=newnode; } int pop(node ** target) { int res=(*target)->val; node * kill = *target; if(*target==NULL) abort(); *target=(*target)->next; free(kill); return res; } }}} == ì´ì •재 == == ì´ì›ì¤€ == *ì—°ê²° 리스트 {{{ #include <stdio.h> typedef struct node{ int v; struct node* next; }node; void freeAll(node* hd); //ê°’ì„ ì¶œë ¥í•˜ë©´ì„œ 구조체를 free int fNum(node* hd); //마지막 êµ¬ì¡°ì²´ì˜ ê°’ì„ ë°˜í™˜ void main(){ node* head; head = (node*)malloc(sizeof(node)); node* temp = head; for (int i = 0; i < 50; i++){ temp->next = (node*)malloc(sizeof(node)); temp->v = i; temp = temp->next; } temp->next = NULL; temp->v = 50; printf("%d\n", fNum(head)); freeAll(head); printf("\n"); } void freeAll(node* hd){ node* ntp; while (hd != NULL){ ntp = hd->next; printf("%d ", hd->v); free(hd); hd = ntp; } } int fNum(node* hd){ int i; node* tp; while (hd != NULL){ i = hd->v; hd = hd->next; } return i; } }}} == 조종현 == == 남헌 == ---- ----------------------------------- [활ë™ì§€ë„/2015] [ìžë£Œêµ¬ì¡±ë°œë³´ìŒˆ]