# Ramazonov Shamshod

 Sana 13.06.2022 Hajmi 432,86 Kb. #665425
Bog'liq
lab5

O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

Dasturlash II
Laboratoriya 5
Ramazonov Shamshod
Variant 24

1. Yangi konteynerlar hosil qiling, uni standart funksiyalar yordamida elementlar bilan to’lating equal funksiyasi yordamida amallar bajaring;

#include
#include
#include
using namespace std;
int main () {
int mymassiv[] = {20,40,60,80,100};
vectormyvector (mymassiv,mymassiv+5);
cout<<"Birinchi holat:"<if ( equal (myvector.begin(), myvector.end(), mymassiv) )
cout << "Mymassiv bilan myvector elementlari teng.\n";
else
cout << "Mymassiv bilan myvector elementlari teng emas.\n";
myvector[3]=81;
cout<<"Ikkinchi holat:"<if ( equal (myvector.begin(), myvector.end(), mymassiv) )
cout << "Mymassiv bilan myvector elementlari teng.\n";
else
cout << "Mymassiv bilan myvector elementlari teng emas.\n";
return 0;
}

for_each(v.begin(), v.end(),chiqar);

cout<system("pause");
return 0;
}

2.Iteratorlardan foydalanib vector konteyneri ustida amallar bajaring;

#include

#include
using namespace std;
int main()
{
int A[5]={1,2,3,5,6};
vector V(5);
V[0]=A[0];
V[1]=A[1];
V[2]=A[2];
V[3]=A[3];
V[4]=A[4];
cout<<"Vector elementlari :"<vector::iterator it;
for(it=V.begin();it!=V.end();it++)
cout<<*it<<" ";
cout<}

3.realloc () funksiyasidan foydalanib xotirani dinamik taqsimlashni amalga
oshiring .

#include"conio.h"

#include
#include
int main(){
int *ptr;
int n, i;
n=5;
printf("Elementlar sonini kiriting: %d\n",n);
ptr=(int*)calloc(n, sizeof(int));
if(ptr==NULL){
printf("Xotira ajratilmagan.\n");
exit(0);
}
else{
printf("Xotira malloc yordamida muvaffaqiyatli ajratildi.\n");
for(i=0;iptr[i]=i+1;
}

}
printf("Massiv elementlari: ");

for(i=0;iprintf("%d, ",ptr[i]);
}
n=10;
printf("\n\nMassivning yangi o'lchamini kiriting: %d\n",n);
ptr=(int*)realloc(ptr,n*sizeof(int));
printf("realloc yordamida xotira muvaffaqiyatli ajratildi.\n");
for(i=5;iptr[i]=i+1;
}
printf("Massiv elementlari: ");
for(i=0;iprintf("%d, ", ptr[i]);
}
free(ptr);
return 0;
}