MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI NURAFSHON FILIALI
“Kompyuter injiniringi” fakulteti
Guruh nomi 710-21AXOʻ
F.I.SH ___Sanoyev Shahriyor
bajargan
№ 4- Laboratoriya ishi
1-vazifa:
Complex sinfidan foydalanib, kompleks sonlar dekrementini (postfiks (i--) uchun) amalga oshiring.
#include
#include
#include
#include
using namespace std;
int sumpost=0;
void postf(valarray&v,int n){
for(int i=0;i}
void showval(valarrayv,int n){
for(int i=0;i}
int main(){
int n,x;
cout<<"Qancha element kiritmoqchisiz"<cin>>n;
valarrayv(n);
for(int i=0;ix=rand()%100+1; v[i]=x; cout<}
cout<postf(v,n);
cout<<"Postfixda "<showval(v,n);
pref(v,n);
return 0;
}
2-vazifa
slice sinfidan foydalanib valarray massiv elementlarini 0 indexdan boshlab har 2 qadamdagilarni 12 tasini aniqlang.
#include
#include
#include
#include
#include
#include
using namespace std;
int main ()
{
valarray < int >vl1 (22);
cout << "Valarray toplam elementlari :\n";
for (int i = 0; i < 22; i++)
{
vl1[i] = rand () % 15-35;
cout << setw (4) << vl1[i];
}
valarray bar = vl1[slice(0,12,2)];
cout << "\n\nNatija: \n";
for (size_t i = 0; i < bar.size (); i++)
{
cout << setw (4) << bar[i];
}
return 0;
}
3-vazifa
gslice sinfidan foydalanib valarray massiv elementlarini 0 indexdan boshlab (2,5) qiymatlar sonida (2,2) qadamdagilar farqi bilan 12 ga toldiring.
#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
valarray < int > vl (50);
int n;
cout << "n= ";
cin >> n;
cout << "valarray toplam elementlari :\n";
for (int i = 0; i < n; i++)
{
vl[i] = rand () % 15;
cout << setw (4) << vl[i];
}
size_t start=0;
size_t uzunlik[]={2,5};
size_t qadam[]={2,2};
gslice ajrat(start,valarray (uzunlik,2),valarray (qadam,12));
vl[ajrat]=5;
cout << "\n\ngslice: \n";
for (size_t i = 0; i < vl.size (); i++)
{
cout << setw (4) << vl[i];
}
}
Asosiy adabiyotlar:
Moʻminov B.B., Dasturlash I. Oʻzbekiston Respublikasi Oliy va oʻrta maxsustaʻlim vazirligi. – T.: «NAMUNA», 2020. –311 b.
Nazirov SH.A., Qobulov R.V., Bobojanov M.R., Raxmanov Q.S. S va C++ tili. “Voris- nashriyot” MCHJ, Toshkent 2013, 488 b.
Horstmann, Cay S. C++ for everyone/Cay S. Horstmann. Printed in the United States of America - 2nd ed. 2010. – P. 562.
Horton I.-Beginning Visual C++ 2012/ I.Horton. Published simultaneously in Canada.–2012. –P. 988.
https://drive.google.com/file/d/1Ans7TBsQBsX_tMIYxURZcLkc_Kp7sAiX/view?usp=sharing
https://drive.google.com/file/d/1HYvMsbIsgUYGfWJj_uxxiR_S9G6G2Q-O/view?usp=sharing
Do'stlaringiz bilan baham: |