Difference between r1.5 and the current
@@ -1,4 +1,4 @@
''점점 탈주자가 생겨나고 있네요''
''점점 탈주자가 생겨나고 있네요 ~~역시 방학~~''
[[TableOfContents]]= 참여자 명단 =
@@ -9,9 +9,8 @@
|| 박인서 || 출석 ||
|| 이정재 || 고향 ||
|| 이원준 || 여행 ||
= 수업 =
== 진행 ==
1. 장소 : 6층 PC실
|| 이정재 || 고향 ||
|| 이원준 || 여행 ||
|| 조종현 || 왜안와 ||
|| 조종현 || 늦잠 ||
|| 남헌 || 출석 ||== 진행 ==
1. 장소 : 6층 PC실
@@ -22,14 +21,12 @@
* 스택 복습
* 큐 만들기
* 문제해결
= 코드 =
== 예제1 ==
= 숙제 =
1. 복습하기
2. 복습하기
3. 복습하기
----
* 큐 만들기
* 문제해결
== 예제1 ==
= 숙제 =
~~0. 지금까지 한 내용 복습하기~~
1. 큐 복습하기
----
@@ -40,11 +37,143 @@
== 최지혁 ==
== 박인서 ==
== 이원준 ==
== 남헌 ==
== 박인서 ==
* 큐
{{{
#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;
head.next=NULL;
push(&head,1);
push(&head,2);
push(&head,3);
push(&head,4);
printf("%d ",pop(&head));
printf("%d ",pop(&head));
printf("%d ",pop(&head));
printf("%d ",pop(&head));
return 0;
}
void push(node * target, int val)
{
node * newnode=(node *)malloc(sizeof(node));
node * temp=target->next;
newnode->val=val;
target->next=newnode;
newnode->next=temp;
}
int pop(node * target)
{
int res;
node * kill=(node *)malloc(sizeof(node));
if(target==NULL) abort();
else if(target->next->next!=NULL) res=pop(target->next);
else
{
res=target->next->val;
kill=target->next;
target->next=NULL;
free(kill);
}
return res;
}
}}}
== 이정재 ==== 이원준 ==
인터넷검색으로 제 맘대로 짜왔슴다.
* ㄴ크 갓원준 클라스 - [박인서]
=== 큐 ===
{{{
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
int v;
struct node* next;
}node;
node* push(node*, int);
int pop(node*);
void freeAll(node*);
void main(){
node head;
head.next = NULL;
node* last = &head;
last = push(last, 1);
last = push(last, 2);
last = push(last, 3);
last = push(last, 4);
printf("%d\n",pop(&head));
printf("%d\n", pop(&head));
printf("---freeAll----\n");
freeAll(&head);
printf("\n");
}
node* push(node* lt, int val){
node* tmp = (node*)malloc(sizeof(node));
tmp->next = NULL;
tmp->v = val;
lt->next = tmp;
lt = lt->next;
return lt;
}
int pop(node* hd){
if (hd->next != NULL) abort;
node* tmp = (node*)malloc(sizeof(node));
int val;
tmp = hd->next;
val = tmp->v;
hd->next = tmp->next;
free(tmp);
return val;
}
void freeAll(node* hd){
node* ntp;
while (hd->next != NULL){
ntp = hd->next;
printf("%d ", ntp->v);
ntp = ntp->next;
free(hd->next);
hd->next = ntp;
}
}
}}}
== 조종현 ==== 남헌 ==
5.3. 박인서 ¶
- 큐
#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; head.next=NULL; push(&head,1); push(&head,2); push(&head,3); push(&head,4); printf("%d ",pop(&head)); printf("%d ",pop(&head)); printf("%d ",pop(&head)); printf("%d ",pop(&head)); return 0; } void push(node * target, int val) { node * newnode=(node *)malloc(sizeof(node)); node * temp=target->next; newnode->val=val; target->next=newnode; newnode->next=temp; } int pop(node * target) { int res; node * kill=(node *)malloc(sizeof(node)); if(target==NULL) abort(); else if(target->next->next!=NULL) res=pop(target->next); else { res=target->next->val; kill=target->next; target->next=NULL; free(kill); } return res; }
5.5.1. 큐 ¶
#include<stdio.h> #include<stdlib.h> typedef struct node{ int v; struct node* next; }node; node* push(node*, int); int pop(node*); void freeAll(node*); void main(){ node head; head.next = NULL; node* last = &head; last = push(last, 1); last = push(last, 2); last = push(last, 3); last = push(last, 4); printf("%d\n",pop(&head)); printf("%d\n", pop(&head)); printf("---freeAll----\n"); freeAll(&head); printf("\n"); } node* push(node* lt, int val){ node* tmp = (node*)malloc(sizeof(node)); tmp->next = NULL; tmp->v = val; lt->next = tmp; lt = lt->next; return lt; } int pop(node* hd){ if (hd->next != NULL) abort; node* tmp = (node*)malloc(sizeof(node)); int val; tmp = hd->next; val = tmp->v; hd->next = tmp->next; free(tmp); return val; } void freeAll(node* hd){ node* ntp; while (hd->next != NULL){ ntp = hd->next; printf("%d ", ntp->v); ntp = ntp->next; free(hd->next); hd->next = ntp; } }