SlideShare a Scribd company logo
KBUZEM
Karabük Üniversitesi
Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Örnek 12.1
#include <conio.h>
using namespace std;
#include <iostream.h>
#include <iostream>
#include <vector>
int main()
{
vector<int> v; //create a vector of ints
v.push_back(10); //put values at end of array
v.push_back(11);
v.push_back(12);
v.push_back(13);
12. HAFTA
NESNEYE DAYALI PROGRAMLAMA
BLM301
Mikroişlemciler
2
v[0] = 20; //replace with new values
v[3] = 23;
for(int j=0; j<v.size(); j++) //display vector contents
cout << v[j] <<" " ; //20 11 12 23
cout << endl;
getch();
return 0;
}
#include <conio.h>
using namespace std;
#include <iostream.h>
#include <iostream>
#include <vector>
// demonstrates constructors, swap(), empty(), back(), pop_back()
using namespace std;
int main()
{ //an array of doubles
int arr[] = { 23, 12, 113, 40 };
vector<int> v1(arr, arr+3); //initialize vector to array
vector<int> v2(3); //empty vector of size 4
v1.swap(v2); //swap contents of v1 and v2
while( !v2.empty() ) //until vector is empty,
{
cout << v2.back() << " "; //display the last element
v2.pop_back(); //remove the last element
}
cout << endl;
getch();
return 0;
}
Örnek 12.3
#include <conio.h>
using namespace std;
#include <iostream.h>
#include <iostream>
#include <vector>
int main()
{
int arr[] = { 100, 110, 120, 130 }; //an array of ints
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
3
vector<int> v(arr, arr+4); //initialize vector to array
cout <<"nBefore insertion:";
for(int j=0; j<v.size(); j++) //display all elements
cout << v[j] <<" ";
v.insert( v.begin()+2, 115); //insert 115 at element 2
cout <<"nAfter insertion:";
for(int j=0; j<v.size(); j++) //display all elements
cout << v[j] <<" ";
v.erase( v.begin()+2 ); //erase element 2
cout << "nAfter erasure:";
for(int j=0; j<v.size(); j++) //display all elements
cout << v[j] << " ";
cout << endl;
getch();
return 0;
}
Örnek 12.4
#include <conio.h>
using namespace std;
#include <iostream.h>
#include <iostream>
//demonstrates push_front(), front(), pop_front()
#include <list>
int main()
{
list<int> ilist;
ilist.push_back(30); //push items on back
ilist.push_back(40);
ilist.push_front(20); //push items on front
ilist.push_front(10);
int size = ilist.size(); //number of items
for(int j=0; j<size; j++)
{
cout << ilist.front() <<" "; //read item from front
ilist.pop_front(); //pop item off front
}
cout << endl;
getch();
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
4
return 0;}
#include <conio.h>
using namespace std;
#include <iostream.h>
#include <iostream>
//demonstrates push_front(), front(), pop_front()
#include <list>
int main()
{
int j;
list<int> list1, list2;
int arr1[] = { 40, 30, 20, 10 };
int arr2[] = { 15, 20, 25, 30, 35 };
for(j=0; j<4; j++)
list1.push_back( arr1[j] ); //list1: 40, 30, 20, 10
for(j=0; j<5; j++)
list2.push_back( arr2[j] ); //list2: 15, 20, 25, 30, 35
list1.reverse(); //reverse list1: 10 20 30 40
list1.merge(list2); //merge list2 into list1
list1.unique(); //remove duplicate 20 and 30
int size = list1.size();
while( !list1.empty() )
{
cout << list1.front() << " "; //read item from front
list1.pop_front(); //pop item off front
}
cout << endl;
getch();
return 0;
}
Örnek 12.6
#include <conio.h>
using namespace std;
#include <iostream.h>
#include <iostream>
#include <deque>
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
5
int main()
{
deque<int> deq;
deq.push_back(30); //push items on back
deq.push_back(40);
deq.push_back(50);
deq.push_front(20); //push items on front
deq.push_front(10);
deq[2] = 33; //change middle item
for(int j=0; j<deq.size(); j++)
cout << deq[j] << " "; //display items
getch();
return 0;
}
Örnek 12.7
#include <conio.h>
#include <iostream.h>
#include <iostream>
using namespace std;
#include <vector>
int main ()
{
vector<int> v;
for (int i=1; i<=15; i++)
{
v.push_back(i);
}
cout << "myvector contains:";
vector<int>::iterator it;
for (it = v.begin() ; it != v.end(); ++it)
cout << ' ' << *it;
cout << 'n';
getch();
return 0;
}
Örnek 12.8
#include <conio.h>
#include <iostream.h>
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
6
#include <iostream>
using namespace std;
#include <vector>
#include <list>
int main()
{
int arr[] = { 2, 4, 6, 8 };
list<int> theList;
for(int k=0; k<4; k++) //fill list with array elements
{ theList.push_back( arr[k] ); }
list<int>::iterator iter; //iterator to list-of-ints
for(iter = theList.begin(); iter != theList.end(); iter++)
{ cout << *iter << " "; } //display the list
cout << endl;
iter = theList.begin();
while( iter != theList.end() )
{cout << *iter++ << " ";}
getch();
return 0;
}
Örnek 12.9
#include <conio.h>
using namespace std;
#include <iostream.h>
#include <iostream>
#include <list>
#include <vector>
int main ()
{
list<int> mylist;
list<int>::iterator it;
// set some initial values:
for (int i=1; i<=5; ++i) mylist.push_back(i); // 1 2 3 4 5
it = mylist.begin();
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
7
++it;
mylist.insert (it,10); // 1 10 2 3 4 5
for (it=mylist.begin(); it!=mylist.end(); ++it) { cout << ' ' << *it; }
getch();
return 0;
}
struct agac {
int kod;
int mal;
};
struct Acc {
list<agac*>agaclistesi;
list<Acc*>acclist;
};
Acc * acc = new Acc();
Acc * acc1 = new Acc();
Acc * acc2 = new Acc();
int al(Acc* t)
{
t->agaclistesi.pop_back();
cout<<t->agaclistesi.size()<<endl; //4 //6
return 0;
}
int main ()
{
agac * cam = new agac();
agac * kavak = new agac();
cam->kod=2;
cam->mal=5;
kavak->kod=9;
kavak->mal=25;
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
8
acc->agaclistesi.push_back(cam);
acc->agaclistesi.push_back(kavak);
acc->agaclistesi.push_back(cam);
acc->agaclistesi.push_back(kavak);
acc1->acclist.push_back(acc);
acc1->acclist.push_back(acc);
cout<<acc1->acclist.size()<<endl; //1
cout<< (acc1->acclist.front())->agaclistesi.size()<<endl; //2
acc2=acc1->acclist.front();
cout<<acc2->agaclistesi.size()<<endl;//3
al(acc1->acclist.front());//4
cout<<acc->agaclistesi.size()<<endl;//5
al(acc);//6
cout<<"son"<<endl; //7
getch();
return 0;
}
#include <conio.h>
#include <iostream>
#include <list>
using namespace std;
struct Acc {
int id;
int hop;
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
9
list<Acc*>acclist;
int al(Acc* a)
{
a->acclist.pop_back();
cout<<a->acclist.size()<<endl;
return 0;
}
};
int main ()
{
Acc * acc1 = new Acc();
Acc * acc2 = new Acc();
Acc * acc3 = new Acc();
acc1->id=1;
acc1->hop=1;
acc2->id=2;
acc2->hop=1;
acc3->id=3;
acc3->hop=1;
acc1->acclist.push_back(acc1);
acc1->acclist.push_front(acc2);
acc1->acclist.push_back(acc3);
cout<<acc1->acclist.size()<<endl; //1
acc1->al(acc1);
cout<< (acc1->acclist.front())->id<<endl; //2
getch();
return 0;
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
10
}
#include <conio.h>
#include <iostream>
#include <list>
using namespace std;
struct Acc {
int id;
int hop;
list<Acc*>acclist;
int al(Acc* a)
{
a->acclist.pop_back();
cout<<a->acclist.size()<<endl;
return 0;
}
};
int main ()
{
Acc * acc1 = new Acc();
Acc * acc2 = new Acc();
Acc * acc3 = new Acc();
acc1->id=1;
acc1->hop=1;
acc2->id=2;
acc2->hop=2;
acc3->id=3;
acc3->hop=3;
acc1->acclist.push_back(acc1);
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
BLM301
Mikroişlemciler
11
acc1->acclist.push_front(acc2);
acc1->acclist.push_back(acc3);
cout<<acc1->acclist.size()<<endl;
list<Acc*>::iterator iter;
iter = acc1->acclist.begin();
while( iter !=acc1->acclist.end() )
{
cout << acc1->acclist.front()->id <<endl;
cout << acc1->acclist.front()->hop <<endl;
*iter++;
acc1->acclist.pop_front();
}
getch();
return 0;
}
Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi
Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE

More Related Content

What's hot

重構—改善既有程式的設計(chapter 9)
重構—改善既有程式的設計(chapter 9)重構—改善既有程式的設計(chapter 9)
重構—改善既有程式的設計(chapter 9)Chris Huang
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia
岳華 杜
 
C++ Programs
C++ ProgramsC++ Programs
C++ Programs
NarayanlalMenariya
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
Manusha Dilan
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
Bastian Feder
 
data Structure Lecture 1
data Structure Lecture 1data Structure Lecture 1
data Structure Lecture 1
Teksify
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
Seok-joon Yun
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The Landing
Haci Murat Yaman
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
kwatch
 
Talk - Query monad
Talk - Query monad Talk - Query monad
Talk - Query monad
Fabernovel
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functionsPrincess Sam
 
Metaprogramming in julia
Metaprogramming in juliaMetaprogramming in julia
Metaprogramming in julia
岳華 杜
 
重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2Chris Huang
 
重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1Chris Huang
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)
David de Boer
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
gourav kottawar
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
Bastian Feder
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
Dhaval Dalal
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
Azul Systems, Inc.
 

What's hot (20)

重構—改善既有程式的設計(chapter 9)
重構—改善既有程式的設計(chapter 9)重構—改善既有程式的設計(chapter 9)
重構—改善既有程式的設計(chapter 9)
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia
 
C++ Programs
C++ ProgramsC++ Programs
C++ Programs
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
data Structure Lecture 1
data Structure Lecture 1data Structure Lecture 1
data Structure Lecture 1
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The Landing
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
 
Talk - Query monad
Talk - Query monad Talk - Query monad
Talk - Query monad
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functions
 
Metaprogramming in julia
Metaprogramming in juliaMetaprogramming in julia
Metaprogramming in julia
 
重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2
 
重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1重構—改善既有程式的設計(chapter 8)part 1
重構—改善既有程式的設計(chapter 8)part 1
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
 
Functions
FunctionsFunctions
Functions
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 

Similar to 12. stl örnekler

C++ practical
C++ practicalC++ practical
C++ practical
Rahul juneja
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
Mouna Guru
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++Dendi Riadi
 
React redux
React reduxReact redux
React redux
Michel Perez
 
Advance java
Advance javaAdvance java
Advance java
Vivek Kumar Sinha
 
Dsprograms(2nd cse)
Dsprograms(2nd cse)Dsprograms(2nd cse)
Dsprograms(2nd cse)
Pradeep Kumar Reddy Reddy
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
AhalyaR
 
14922 java script built (1)
14922 java script built (1)14922 java script built (1)
14922 java script built (1)
dineshrana201992
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)
Syed Umair
 
Part APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docxPart APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docx
dewhirstichabod
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
afgt2012
 
CppTutorial.ppt
CppTutorial.pptCppTutorial.ppt
CppTutorial.ppt
HODZoology3
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
Vikas Sharma
 
Lecture#8 introduction to array with examples c++
Lecture#8 introduction to array with examples c++Lecture#8 introduction to array with examples c++
Lecture#8 introduction to array with examples c++
NUST Stuff
 
ios,objective tutorial
ios,objective tutorial ios,objective tutorial
ios,objective tutorial
Bhavik Patel
 
Codes on structures
Codes on structuresCodes on structures
Codes on structures
Shakila Mahjabin
 

Similar to 12. stl örnekler (20)

C++ practical
C++ practicalC++ practical
C++ practical
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
React redux
React reduxReact redux
React redux
 
Advance java
Advance javaAdvance java
Advance java
 
Dsprograms(2nd cse)
Dsprograms(2nd cse)Dsprograms(2nd cse)
Dsprograms(2nd cse)
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
14922 java script built (1)
14922 java script built (1)14922 java script built (1)
14922 java script built (1)
 
C++ programs
C++ programsC++ programs
C++ programs
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)
 
Part APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docxPart APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docx
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
 
CppTutorial.ppt
CppTutorial.pptCppTutorial.ppt
CppTutorial.ppt
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Lecture#8 introduction to array with examples c++
Lecture#8 introduction to array with examples c++Lecture#8 introduction to array with examples c++
Lecture#8 introduction to array with examples c++
 
ios,objective tutorial
ios,objective tutorial ios,objective tutorial
ios,objective tutorial
 
Codes on structures
Codes on structuresCodes on structures
Codes on structures
 

More from karmuhtam

Devre analizi deney malzeme listesi
Devre analizi deney malzeme listesiDevre analizi deney malzeme listesi
Devre analizi deney malzeme listesi
karmuhtam
 
Deney 6
Deney 6Deney 6
Deney 6
karmuhtam
 
Deney 5
Deney 5Deney 5
Deney 5
karmuhtam
 
Deney 3 ve 4
Deney 3 ve 4Deney 3 ve 4
Deney 3 ve 4
karmuhtam
 
Deney 1 ve 2
Deney 1 ve 2Deney 1 ve 2
Deney 1 ve 2
karmuhtam
 
Data structure week y 5 1
Data structure week y 5 1Data structure week y 5 1
Data structure week y 5 1
karmuhtam
 
Data structure week y 5
Data structure week y 5Data structure week y 5
Data structure week y 5
karmuhtam
 
Data structure week y 4
Data structure week y 4Data structure week y 4
Data structure week y 4
karmuhtam
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3
karmuhtam
 
Data structure week 2
Data structure week 2Data structure week 2
Data structure week 2
karmuhtam
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
karmuhtam
 
13. sınıfları başlık dosyaları
13.  sınıfları başlık dosyaları13.  sınıfları başlık dosyaları
13. sınıfları başlık dosyaları
karmuhtam
 
11. stl kütüphanesi
11. stl kütüphanesi11. stl kütüphanesi
11. stl kütüphanesi
karmuhtam
 
10. istisna isleme
10. istisna isleme10. istisna isleme
10. istisna isleme
karmuhtam
 
9. şablonlar
9. şablonlar9. şablonlar
9. şablonlar
karmuhtam
 
8. çok biçimlilik
8. çok biçimlilik8. çok biçimlilik
8. çok biçimlilik
karmuhtam
 
7. kalıtım
7. kalıtım7. kalıtım
7. kalıtım
karmuhtam
 
6. this işaretçisi ve arkadaşlık
6. this işaretçisi ve arkadaşlık6. this işaretçisi ve arkadaşlık
6. this işaretçisi ve arkadaşlık
karmuhtam
 
5. kurucu, yok edici ve kopyalama fonksiyonları
5. kurucu, yok edici ve kopyalama fonksiyonları5. kurucu, yok edici ve kopyalama fonksiyonları
5. kurucu, yok edici ve kopyalama fonksiyonları
karmuhtam
 
4. yapılar
4. yapılar4. yapılar
4. yapılar
karmuhtam
 

More from karmuhtam (20)

Devre analizi deney malzeme listesi
Devre analizi deney malzeme listesiDevre analizi deney malzeme listesi
Devre analizi deney malzeme listesi
 
Deney 6
Deney 6Deney 6
Deney 6
 
Deney 5
Deney 5Deney 5
Deney 5
 
Deney 3 ve 4
Deney 3 ve 4Deney 3 ve 4
Deney 3 ve 4
 
Deney 1 ve 2
Deney 1 ve 2Deney 1 ve 2
Deney 1 ve 2
 
Data structure week y 5 1
Data structure week y 5 1Data structure week y 5 1
Data structure week y 5 1
 
Data structure week y 5
Data structure week y 5Data structure week y 5
Data structure week y 5
 
Data structure week y 4
Data structure week y 4Data structure week y 4
Data structure week y 4
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3
 
Data structure week 2
Data structure week 2Data structure week 2
Data structure week 2
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
 
13. sınıfları başlık dosyaları
13.  sınıfları başlık dosyaları13.  sınıfları başlık dosyaları
13. sınıfları başlık dosyaları
 
11. stl kütüphanesi
11. stl kütüphanesi11. stl kütüphanesi
11. stl kütüphanesi
 
10. istisna isleme
10. istisna isleme10. istisna isleme
10. istisna isleme
 
9. şablonlar
9. şablonlar9. şablonlar
9. şablonlar
 
8. çok biçimlilik
8. çok biçimlilik8. çok biçimlilik
8. çok biçimlilik
 
7. kalıtım
7. kalıtım7. kalıtım
7. kalıtım
 
6. this işaretçisi ve arkadaşlık
6. this işaretçisi ve arkadaşlık6. this işaretçisi ve arkadaşlık
6. this işaretçisi ve arkadaşlık
 
5. kurucu, yok edici ve kopyalama fonksiyonları
5. kurucu, yok edici ve kopyalama fonksiyonları5. kurucu, yok edici ve kopyalama fonksiyonları
5. kurucu, yok edici ve kopyalama fonksiyonları
 
4. yapılar
4. yapılar4. yapılar
4. yapılar
 

Recently uploaded

Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 

Recently uploaded (20)

Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 

12. stl örnekler

  • 1. KBUZEM Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Örnek 12.1 #include <conio.h> using namespace std; #include <iostream.h> #include <iostream> #include <vector> int main() { vector<int> v; //create a vector of ints v.push_back(10); //put values at end of array v.push_back(11); v.push_back(12); v.push_back(13); 12. HAFTA NESNEYE DAYALI PROGRAMLAMA
  • 2. BLM301 Mikroişlemciler 2 v[0] = 20; //replace with new values v[3] = 23; for(int j=0; j<v.size(); j++) //display vector contents cout << v[j] <<" " ; //20 11 12 23 cout << endl; getch(); return 0; } #include <conio.h> using namespace std; #include <iostream.h> #include <iostream> #include <vector> // demonstrates constructors, swap(), empty(), back(), pop_back() using namespace std; int main() { //an array of doubles int arr[] = { 23, 12, 113, 40 }; vector<int> v1(arr, arr+3); //initialize vector to array vector<int> v2(3); //empty vector of size 4 v1.swap(v2); //swap contents of v1 and v2 while( !v2.empty() ) //until vector is empty, { cout << v2.back() << " "; //display the last element v2.pop_back(); //remove the last element } cout << endl; getch(); return 0; } Örnek 12.3 #include <conio.h> using namespace std; #include <iostream.h> #include <iostream> #include <vector> int main() { int arr[] = { 100, 110, 120, 130 }; //an array of ints Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 3. BLM301 Mikroişlemciler 3 vector<int> v(arr, arr+4); //initialize vector to array cout <<"nBefore insertion:"; for(int j=0; j<v.size(); j++) //display all elements cout << v[j] <<" "; v.insert( v.begin()+2, 115); //insert 115 at element 2 cout <<"nAfter insertion:"; for(int j=0; j<v.size(); j++) //display all elements cout << v[j] <<" "; v.erase( v.begin()+2 ); //erase element 2 cout << "nAfter erasure:"; for(int j=0; j<v.size(); j++) //display all elements cout << v[j] << " "; cout << endl; getch(); return 0; } Örnek 12.4 #include <conio.h> using namespace std; #include <iostream.h> #include <iostream> //demonstrates push_front(), front(), pop_front() #include <list> int main() { list<int> ilist; ilist.push_back(30); //push items on back ilist.push_back(40); ilist.push_front(20); //push items on front ilist.push_front(10); int size = ilist.size(); //number of items for(int j=0; j<size; j++) { cout << ilist.front() <<" "; //read item from front ilist.pop_front(); //pop item off front } cout << endl; getch(); Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 4. BLM301 Mikroişlemciler 4 return 0;} #include <conio.h> using namespace std; #include <iostream.h> #include <iostream> //demonstrates push_front(), front(), pop_front() #include <list> int main() { int j; list<int> list1, list2; int arr1[] = { 40, 30, 20, 10 }; int arr2[] = { 15, 20, 25, 30, 35 }; for(j=0; j<4; j++) list1.push_back( arr1[j] ); //list1: 40, 30, 20, 10 for(j=0; j<5; j++) list2.push_back( arr2[j] ); //list2: 15, 20, 25, 30, 35 list1.reverse(); //reverse list1: 10 20 30 40 list1.merge(list2); //merge list2 into list1 list1.unique(); //remove duplicate 20 and 30 int size = list1.size(); while( !list1.empty() ) { cout << list1.front() << " "; //read item from front list1.pop_front(); //pop item off front } cout << endl; getch(); return 0; } Örnek 12.6 #include <conio.h> using namespace std; #include <iostream.h> #include <iostream> #include <deque> Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 5. BLM301 Mikroişlemciler 5 int main() { deque<int> deq; deq.push_back(30); //push items on back deq.push_back(40); deq.push_back(50); deq.push_front(20); //push items on front deq.push_front(10); deq[2] = 33; //change middle item for(int j=0; j<deq.size(); j++) cout << deq[j] << " "; //display items getch(); return 0; } Örnek 12.7 #include <conio.h> #include <iostream.h> #include <iostream> using namespace std; #include <vector> int main () { vector<int> v; for (int i=1; i<=15; i++) { v.push_back(i); } cout << "myvector contains:"; vector<int>::iterator it; for (it = v.begin() ; it != v.end(); ++it) cout << ' ' << *it; cout << 'n'; getch(); return 0; } Örnek 12.8 #include <conio.h> #include <iostream.h> Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 6. BLM301 Mikroişlemciler 6 #include <iostream> using namespace std; #include <vector> #include <list> int main() { int arr[] = { 2, 4, 6, 8 }; list<int> theList; for(int k=0; k<4; k++) //fill list with array elements { theList.push_back( arr[k] ); } list<int>::iterator iter; //iterator to list-of-ints for(iter = theList.begin(); iter != theList.end(); iter++) { cout << *iter << " "; } //display the list cout << endl; iter = theList.begin(); while( iter != theList.end() ) {cout << *iter++ << " ";} getch(); return 0; } Örnek 12.9 #include <conio.h> using namespace std; #include <iostream.h> #include <iostream> #include <list> #include <vector> int main () { list<int> mylist; list<int>::iterator it; // set some initial values: for (int i=1; i<=5; ++i) mylist.push_back(i); // 1 2 3 4 5 it = mylist.begin(); Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 7. BLM301 Mikroişlemciler 7 ++it; mylist.insert (it,10); // 1 10 2 3 4 5 for (it=mylist.begin(); it!=mylist.end(); ++it) { cout << ' ' << *it; } getch(); return 0; } struct agac { int kod; int mal; }; struct Acc { list<agac*>agaclistesi; list<Acc*>acclist; }; Acc * acc = new Acc(); Acc * acc1 = new Acc(); Acc * acc2 = new Acc(); int al(Acc* t) { t->agaclistesi.pop_back(); cout<<t->agaclistesi.size()<<endl; //4 //6 return 0; } int main () { agac * cam = new agac(); agac * kavak = new agac(); cam->kod=2; cam->mal=5; kavak->kod=9; kavak->mal=25; Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 8. BLM301 Mikroişlemciler 8 acc->agaclistesi.push_back(cam); acc->agaclistesi.push_back(kavak); acc->agaclistesi.push_back(cam); acc->agaclistesi.push_back(kavak); acc1->acclist.push_back(acc); acc1->acclist.push_back(acc); cout<<acc1->acclist.size()<<endl; //1 cout<< (acc1->acclist.front())->agaclistesi.size()<<endl; //2 acc2=acc1->acclist.front(); cout<<acc2->agaclistesi.size()<<endl;//3 al(acc1->acclist.front());//4 cout<<acc->agaclistesi.size()<<endl;//5 al(acc);//6 cout<<"son"<<endl; //7 getch(); return 0; } #include <conio.h> #include <iostream> #include <list> using namespace std; struct Acc { int id; int hop; Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 9. BLM301 Mikroişlemciler 9 list<Acc*>acclist; int al(Acc* a) { a->acclist.pop_back(); cout<<a->acclist.size()<<endl; return 0; } }; int main () { Acc * acc1 = new Acc(); Acc * acc2 = new Acc(); Acc * acc3 = new Acc(); acc1->id=1; acc1->hop=1; acc2->id=2; acc2->hop=1; acc3->id=3; acc3->hop=1; acc1->acclist.push_back(acc1); acc1->acclist.push_front(acc2); acc1->acclist.push_back(acc3); cout<<acc1->acclist.size()<<endl; //1 acc1->al(acc1); cout<< (acc1->acclist.front())->id<<endl; //2 getch(); return 0; Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 10. BLM301 Mikroişlemciler 10 } #include <conio.h> #include <iostream> #include <list> using namespace std; struct Acc { int id; int hop; list<Acc*>acclist; int al(Acc* a) { a->acclist.pop_back(); cout<<a->acclist.size()<<endl; return 0; } }; int main () { Acc * acc1 = new Acc(); Acc * acc2 = new Acc(); Acc * acc3 = new Acc(); acc1->id=1; acc1->hop=1; acc2->id=2; acc2->hop=2; acc3->id=3; acc3->hop=3; acc1->acclist.push_back(acc1); Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE
  • 11. BLM301 Mikroişlemciler 11 acc1->acclist.push_front(acc2); acc1->acclist.push_back(acc3); cout<<acc1->acclist.size()<<endl; list<Acc*>::iterator iter; iter = acc1->acclist.begin(); while( iter !=acc1->acclist.end() ) { cout << acc1->acclist.front()->id <<endl; cout << acc1->acclist.front()->hop <<endl; *iter++; acc1->acclist.pop_front(); } getch(); return 0; } Karabük Üniversitesi Uzaktan Eğitim Araştırma ve Uygulama Merkezi Mühendislik Fakültesi No: 215 Balıklarkayası Mevkii 78050 Karabük TÜRKİYE