Std; int main { multiset


Download 30.42 Kb.
Sana31.01.2024
Hajmi30.42 Kb.
#1817566
Bog'liq
multiset


Multisetning setdan farqi shundagi u ro`yxatdagi ma`lumotlarni bir xillarini olib tashlaymadi
.begin() va .end() parametrlarini ishlatilishi
#include
#include
using namespace std;
int main ()
{
multiset<string> mymultiset= {"Java", "C++", "SQL","C++"};
cout<<"Multiset ro`yxati: "<;
for (multiset<string>::iterator it=mymultiset.begin(); it!=mymultiset.end(); ++it)
cout << *it<< '\n';
return 0;
}

Multiset ro`yxati:


C++
C++
Java
SQL

Size() funksiyasi ham set bilan juda o`xshash lekin setdan bitta farqi shuki multisetda ikkita bir xil o`zgaruvchini ham hisoblaydi.


#include
#include
using namespace std;
int main()
{
multiset son {'a', 'b', 'c', 'd', 'a'};
cout << "Multisetda" << son.size() << " ta element bor\n";
return 0;
}

Multsetda 5ta element bor


#include


#include
using namespace std;
int main()
{
multiset my_multiset;
my_multiset.insert(1);
my_multiset.insert(4);
my_multiset.insert(2);
my_multiset.insert(3);
my_multiset.insert(3);
cout << "My_multiset ro`yxati elementlari: ";
for (auto it = my_multiset.begin(); it != my_multiset.end(); it++)
cout << *it << " ";
return 0;
}

My_multiset ro`yxati elementlari: 1 2 3 3 4


.find() parametri bu qidirsh parametri bo`lib siz islayotgan malumot ro`yxatdan bor bo`lsa uni topib yangi o`zgaruvchiga o`zlashtirib beradi.


#include


#include
using namespace std;
int main(void) {
multiset my_multiset = {100,200,300,300};
auto it = my_multiset.find(300);
cout << "Siz qidirgan element: " << *it << endl;
return 0;
}


Siz qidirgan element: 300

Download 30.42 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling