Labaratoriya ishi № 4
5 - variant
Bajardi: Atoyev B
Tekshirdi: Dauletov A
Yangi konteynerlar hosil qiling, uni standart funksiyalar yordamida elementlar bilan to’lating search funksiyasi yordamida amallar bajaring;
Iteratorlardan foydalanib multimap konteyneri ustida amallar bajaring;
calloc () funksiyasidan foydalanib xotirani dinamik taqsimlashni amalga oshiring .
a)
#include
#include
using namespace std;
int main()
{
vector ivec;
int a, n, b, q = 1;
cout << "Konteyner elementlari sonini kiriting = "; cin >> n;
for (int i = 1; i <= n; i++)
{
a = rand() % 20;
ivec.push_back(a);
cout << "\nKonteynerning " << i << " - elementini = "<}
cout << "\nQidirilayotga sonni kiriting = "; cin >> b;
for (int i = 1; i <= n; i++)
{
if (ivec.back() == b)
{
cout << n - q + 1 << " - element = " << ivec.back() << " ga teng";
return 0;
}
q++;
ivec.pop_back();
}
return 0;
}
b)
#include
#include
Do'stlaringiz bilan baham: |