SlideShare una empresa de Scribd logo
1 de 15
[자료구조] 쏭치
스터디 필수 사항 스터디에한번이라도 빠지면 영영스터디에서 빠져주세요. 과제가 좀 많을 꺼애요 과제 못하면 벌금이 있을꺼애요~
오늘의 Topic 포인터 구조체 Linked List
포인터 왜 쓸까?? 모든 자료형의 포인터는 4byte 메모리에 있는 주소를 가리킨다 주소연산자 ‘&’ 참조연산자 ‘*’ 메모리 할당 malloc 메모리 할당 해제 free
출력 결과는?? charc[100]; double d[100]; char *ptr_c=c; double *ptr_d=d; printf(“%d %d”, sizeof(c), sizeof(ptr_c)); printf(“%d %d”, sizeof(d), sizeof(ptr_d));
구조체 같거나 다른 자료형을 모아서 새로운 자료형처럼 사용 멤버 변수에 접근 방법 일반변수로 선언했을 경우 "." (직접참조) 포인터로 선언했을 경우 "->" (간접참조)
구조체 사용의 예 typedefstruct{ int age; char name[10]; }node; node v, *ptr_v=(node*)malloc(sizeof(node)); v.age = 100; ptr_v->age = 100;
이런 경우 어떻게 접근하나요? typedefstruct{ int parameter; }item; typedefstruct{ char name[10]; 	item t1, *t2; }node; node obj1, *obj2=(node*)malloc(sizeof(node)); obj1으로 t1의 parameter에 접근? obj1으로 t2의 parameter에 접근? obj2으로 t1의 parameter에 접근? obj2으로 t2의 parameter에 접근?
Linked List 자료를 중간에 삽입, 삭제 시 용이함 첫 Node를 가리키는 ”head” 마지막 Node를 가리키는 “tail” 단순 연결 리스트, 원형 연결 리스트, 이중 연결 리스트 등이 존재 Pointer에 대한 이해가 필수 스터디에서 할 건 단순 연결 리스트
단순 연결 리스트 그림 * * * * * NULL
단순 연결 리스트 구현 typedefstruct_node{ int item; struct node *next; }node; typedefstruct{ int item; struct node *next; }node;
단순 연결 리스트 구현 int main(){ 	node *head = NULL; 	// … 삽입 루틴 if(head == NULL){ 		head = (node_ptr)malloc(sizeof(node)); 		head->next = NULL; 		head->item = 1; 	} else insert(head, 2); 	return 0; }
단순 연결 리스트 구현 void insert(node_ptr head, int item){ node_ptrnewItem = (node_ptr)malloc(sizeof(node)); newItem->item = item; newItem->next = NULL; while(head->next != NULL){ 		head=head->next; 	} 	head->next = newItem; }
단순 연결 리스트에서의 삭제 * * * * * NULL
단순 연결 리스트에서의 삭제 void del(node_ptr head, int item){ while(head->next != NULL && head->next->item != item){ 		head=head->next; 	} if(head->next->item == item){node_ptr temp = head->next; 		head->next=head->next->next; freetemp;} }

Más contenido relacionado

La actualidad más candente

자료구조 Project5
자료구조 Project5자료구조 Project5
자료구조 Project5
KoChungWook
 
Python3 10장 문자열이야기
Python3 10장 문자열이야기Python3 10장 문자열이야기
Python3 10장 문자열이야기
Jihoon Kong
 
2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf
kd19h
 
2012 Ds D2 03
2012 Ds D2 032012 Ds D2 03
2012 Ds D2 03
chl132435
 
C 언어 스터디 03 - 배열, 포인터
C 언어 스터디 03 - 배열, 포인터C 언어 스터디 03 - 배열, 포인터
C 언어 스터디 03 - 배열, 포인터
Yu Yongwoo
 

La actualidad más candente (20)

변수 이름의 효과
변수 이름의 효과변수 이름의 효과
변수 이름의 효과
 
Regex
RegexRegex
Regex
 
자료구조 Project5
자료구조 Project5자료구조 Project5
자료구조 Project5
 
자구4번
자구4번자구4번
자구4번
 
자료구조04
자료구조04자료구조04
자료구조04
 
Python3 10장 문자열이야기
Python3 10장 문자열이야기Python3 10장 문자열이야기
Python3 10장 문자열이야기
 
파이썬 데이터 분석 3종세트
파이썬 데이터 분석 3종세트파이썬 데이터 분석 3종세트
파이썬 데이터 분석 3종세트
 
2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf
 
파이썬을 활용한 자연어 분석 - 2차
파이썬을 활용한 자연어 분석 - 2차파이썬을 활용한 자연어 분석 - 2차
파이썬을 활용한 자연어 분석 - 2차
 
Python - Module
Python - ModulePython - Module
Python - Module
 
문과생 대상 파이썬을 활용한 데이터 분석 강의
문과생 대상 파이썬을 활용한 데이터 분석 강의문과생 대상 파이썬을 활용한 데이터 분석 강의
문과생 대상 파이썬을 활용한 데이터 분석 강의
 
2012 Ds D2 03
2012 Ds D2 032012 Ds D2 03
2012 Ds D2 03
 
C 언어 스터디 03 - 배열, 포인터
C 언어 스터디 03 - 배열, 포인터C 언어 스터디 03 - 배열, 포인터
C 언어 스터디 03 - 배열, 포인터
 
4.representing data and engineering features
4.representing data and engineering features4.representing data and engineering features
4.representing data and engineering features
 
서울 R&D 캠퍼스 자연어 수업자료
서울 R&D 캠퍼스 자연어 수업자료서울 R&D 캠퍼스 자연어 수업자료
서울 R&D 캠퍼스 자연어 수업자료
 
파이썬을 활용한 자연어 분석 - 추가분
파이썬을 활용한 자연어 분석 - 추가분파이썬을 활용한 자연어 분석 - 추가분
파이썬을 활용한 자연어 분석 - 추가분
 
Python basic
Python basicPython basic
Python basic
 
파이썬과 자연어 4 | word/doc2vec
파이썬과 자연어 4 | word/doc2vec파이썬과 자연어 4 | word/doc2vec
파이썬과 자연어 4 | word/doc2vec
 
파이썬과 자연어 1 | Word Cloud
파이썬과 자연어 1 | Word Cloud파이썬과 자연어 1 | Word Cloud
파이썬과 자연어 1 | Word Cloud
 
LDA : latent Dirichlet Allocation (Fairies NLP Series) - Korean Ver.
LDA : latent Dirichlet Allocation (Fairies NLP Series) - Korean Ver.LDA : latent Dirichlet Allocation (Fairies NLP Series) - Korean Ver.
LDA : latent Dirichlet Allocation (Fairies NLP Series) - Korean Ver.
 

Destacado

P. editorial con PLP
P. editorial con PLPP. editorial con PLP
P. editorial con PLP
Andrea Brunet
 
Intro to tsql unit 12
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12
Syed Asrarali
 
New microsoft word document (3)
New microsoft word document (3)New microsoft word document (3)
New microsoft word document (3)
Bankesh
 
Space camp turkey
Space camp turkeySpace camp turkey
Space camp turkey
y3ehps
 
Eta introdution
Eta introdutionEta introdution
Eta introdution
Lee Joe
 

Destacado (20)

P. editorial con PLP
P. editorial con PLPP. editorial con PLP
P. editorial con PLP
 
Summit Struggles In Light Of 21 Ordinance
Summit Struggles In Light Of 21 OrdinanceSummit Struggles In Light Of 21 Ordinance
Summit Struggles In Light Of 21 Ordinance
 
Query optimization for_sensor_networks
Query optimization for_sensor_networksQuery optimization for_sensor_networks
Query optimization for_sensor_networks
 
Pràctica 2 del curs Cloud Computing.
Pràctica 2 del curs Cloud Computing.Pràctica 2 del curs Cloud Computing.
Pràctica 2 del curs Cloud Computing.
 
DIA DE LA TRADICIÓN
DIA DE LA TRADICIÓNDIA DE LA TRADICIÓN
DIA DE LA TRADICIÓN
 
Pantallazos
PantallazosPantallazos
Pantallazos
 
Intro to tsql unit 12
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12
 
New microsoft word document (3)
New microsoft word document (3)New microsoft word document (3)
New microsoft word document (3)
 
Space camp turkey
Space camp turkeySpace camp turkey
Space camp turkey
 
Eta introdution
Eta introdutionEta introdution
Eta introdution
 
Case Rajatori 2011
Case Rajatori 2011Case Rajatori 2011
Case Rajatori 2011
 
Pictures of earth
Pictures of earthPictures of earth
Pictures of earth
 
Building the Right Team to Insure Social Media Success
Building the Right Team to Insure Social Media SuccessBuilding the Right Team to Insure Social Media Success
Building the Right Team to Insure Social Media Success
 
Printer
PrinterPrinter
Printer
 
Pantallazos
PantallazosPantallazos
Pantallazos
 
Center parcs
Center parcsCenter parcs
Center parcs
 
Bridge Model ASA 2012
Bridge Model ASA 2012Bridge Model ASA 2012
Bridge Model ASA 2012
 
GolinHarris 2013 Al's Day: Day of Service
GolinHarris 2013 Al's Day: Day of ServiceGolinHarris 2013 Al's Day: Day of Service
GolinHarris 2013 Al's Day: Day of Service
 
Energy
EnergyEnergy
Energy
 
Microsoft Azure 08.2014
Microsoft Azure 08.2014Microsoft Azure 08.2014
Microsoft Azure 08.2014
 

Similar a Study1

사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
Esun Kim
 
읽기 좋은 코드가 좋은 코드다 Part one
읽기 좋은 코드가 좋은 코드다   Part one읽기 좋은 코드가 좋은 코드다   Part one
읽기 좋은 코드가 좋은 코드다 Part one
Ji Hun Kim
 
[0820 석재호]headfirst디자인패턴
[0820 석재호]headfirst디자인패턴[0820 석재호]headfirst디자인패턴
[0820 석재호]headfirst디자인패턴
Jaeho Seok
 
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
Sang Don Kim
 

Similar a Study1 (20)

사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
사례를 통해 살펴보는 프로파일링과 최적화 NDC2013
 
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14
 
파이썬 데이터 분석 (18년)
파이썬 데이터 분석 (18년)파이썬 데이터 분석 (18년)
파이썬 데이터 분석 (18년)
 
Programming skills 1부
Programming skills 1부Programming skills 1부
Programming skills 1부
 
G+ Summer C Study 20130703(1일차)
G+ Summer C Study 20130703(1일차)G+ Summer C Study 20130703(1일차)
G+ Summer C Study 20130703(1일차)
 
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영)
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영) 파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영)
파이썬 데이터과학 레벨1 - 초보자를 위한 데이터분석, 데이터시각화 (2020년 이태영)
 
[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기
 
읽기 좋은 코드가 좋은 코드다 Part one
읽기 좋은 코드가 좋은 코드다   Part one읽기 좋은 코드가 좋은 코드다   Part one
읽기 좋은 코드가 좋은 코드다 Part one
 
온라인 게임에서 사례로 살펴보는 디버깅 in NDC2010
온라인 게임에서 사례로 살펴보는 디버깅 in NDC2010온라인 게임에서 사례로 살펴보는 디버깅 in NDC2010
온라인 게임에서 사례로 살펴보는 디버깅 in NDC2010
 
온라인 게임에서 사례로 살펴보는 디버깅 in NDC10
온라인 게임에서 사례로 살펴보는 디버깅 in NDC10온라인 게임에서 사례로 살펴보는 디버깅 in NDC10
온라인 게임에서 사례로 살펴보는 디버깅 in NDC10
 
[0820 석재호]headfirst디자인패턴
[0820 석재호]headfirst디자인패턴[0820 석재호]headfirst디자인패턴
[0820 석재호]headfirst디자인패턴
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)
 
C review
C  reviewC  review
C review
 
05장 논리적 자료표현: 구조체
05장 논리적 자료표현: 구조체05장 논리적 자료표현: 구조체
05장 논리적 자료표현: 구조체
 
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
 
포인터의기초 (2) - 포인터 사용하기1
포인터의기초 (2) - 포인터 사용하기1포인터의기초 (2) - 포인터 사용하기1
포인터의기초 (2) - 포인터 사용하기1
 
C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부
 
Python vs Java @ PyCon Korea 2017
Python vs Java @ PyCon Korea 2017Python vs Java @ PyCon Korea 2017
Python vs Java @ PyCon Korea 2017
 
Java Class File Format
Java Class File FormatJava Class File Format
Java Class File Format
 

Más de SongChiWon

Más de SongChiWon (8)

Study3
Study3Study3
Study3
 
Study3
Study3Study3
Study3
 
Study2
Study2Study2
Study2
 
Study1
Study1Study1
Study1
 
Study2
Study2Study2
Study2
 
Study3
Study3Study3
Study3
 
제발 이런 실수는 이제 그만
제발 이런 실수는 이제 그만제발 이런 실수는 이제 그만
제발 이런 실수는 이제 그만
 
Stack
StackStack
Stack
 

Study1

  • 2. 스터디 필수 사항 스터디에한번이라도 빠지면 영영스터디에서 빠져주세요. 과제가 좀 많을 꺼애요 과제 못하면 벌금이 있을꺼애요~
  • 3. 오늘의 Topic 포인터 구조체 Linked List
  • 4. 포인터 왜 쓸까?? 모든 자료형의 포인터는 4byte 메모리에 있는 주소를 가리킨다 주소연산자 ‘&’ 참조연산자 ‘*’ 메모리 할당 malloc 메모리 할당 해제 free
  • 5. 출력 결과는?? charc[100]; double d[100]; char *ptr_c=c; double *ptr_d=d; printf(“%d %d”, sizeof(c), sizeof(ptr_c)); printf(“%d %d”, sizeof(d), sizeof(ptr_d));
  • 6. 구조체 같거나 다른 자료형을 모아서 새로운 자료형처럼 사용 멤버 변수에 접근 방법 일반변수로 선언했을 경우 "." (직접참조) 포인터로 선언했을 경우 "->" (간접참조)
  • 7. 구조체 사용의 예 typedefstruct{ int age; char name[10]; }node; node v, *ptr_v=(node*)malloc(sizeof(node)); v.age = 100; ptr_v->age = 100;
  • 8. 이런 경우 어떻게 접근하나요? typedefstruct{ int parameter; }item; typedefstruct{ char name[10]; item t1, *t2; }node; node obj1, *obj2=(node*)malloc(sizeof(node)); obj1으로 t1의 parameter에 접근? obj1으로 t2의 parameter에 접근? obj2으로 t1의 parameter에 접근? obj2으로 t2의 parameter에 접근?
  • 9. Linked List 자료를 중간에 삽입, 삭제 시 용이함 첫 Node를 가리키는 ”head” 마지막 Node를 가리키는 “tail” 단순 연결 리스트, 원형 연결 리스트, 이중 연결 리스트 등이 존재 Pointer에 대한 이해가 필수 스터디에서 할 건 단순 연결 리스트
  • 10. 단순 연결 리스트 그림 * * * * * NULL
  • 11. 단순 연결 리스트 구현 typedefstruct_node{ int item; struct node *next; }node; typedefstruct{ int item; struct node *next; }node;
  • 12. 단순 연결 리스트 구현 int main(){ node *head = NULL; // … 삽입 루틴 if(head == NULL){ head = (node_ptr)malloc(sizeof(node)); head->next = NULL; head->item = 1; } else insert(head, 2); return 0; }
  • 13. 단순 연결 리스트 구현 void insert(node_ptr head, int item){ node_ptrnewItem = (node_ptr)malloc(sizeof(node)); newItem->item = item; newItem->next = NULL; while(head->next != NULL){ head=head->next; } head->next = newItem; }
  • 14. 단순 연결 리스트에서의 삭제 * * * * * NULL
  • 15. 단순 연결 리스트에서의 삭제 void del(node_ptr head, int item){ while(head->next != NULL && head->next->item != item){ head=head->next; } if(head->next->item == item){node_ptr temp = head->next; head->next=head->next->next; freetemp;} }