3 Vector k elementidan l elementigacha bo’lgan elementlarning o’rtacha qiymatidan hisoblansin
Download 383.47 Kb.
|
2-Amaliyot ishi
2-Amaliyot 3)Vector k – elementidan l – elementigacha bo’lgan elementlarning o’rtacha qiymatidan hisoblansin. #include using namespace std; vector int main(){ int n,k,l,f; float s=0,c,q=0,m; cout<<"Vector o'lchamini kiriting :"; cin>>n; for(int i=0;i a.push_back(c);} cout<<"k - elementi l - elementini kiriting:"; cin>>k>>l; for(int i=0;i s+=a[i];q++;} cout<<"\n---------Natija----------\n\n "; s/q; cout<<"Javob: "< } } Vector o'lchamini kiriting :4 vectorning 0 elementi: 2 vectorning 1 elementi: 4 vectorning 2 elementi: 6 vectorning 3 elementi: 8 k - elementi l - elementini kiriting:2 4 ---------Natija---------- Javob: 3.85672e-039 Process returned 0 (0x0) execution time : 30.189 s Press any key to continue. 2)Vektorning elementlari vektoning eng katta elementiga bo’lib chiqilsin. #include using namespace std; vector int main(){ int n; float max,l,f; cout<<"Vector o'lchamini kiriting :"; cin>>n; for(int i=0;i a.push_back(l);} max=a[0]; for(int i=0;i max=a[i]; }} cout<<" \n---------Natija------------\n\n "; for(int i=0;i cout< 3) Vektor tоk o`rindagi elementlarini yig’indisi hisoblansin #include using namespace std; vector int main(){ int n,k=1; float s=0,l; cout<<"Vector o'lchamini kiriting :"; cin>>n; for(int i=0;i a.push_back(l);} for(int i=0;i s+=a[i]; } k++;} cout<<" \n---------Natija------------\n\n "; cout<<"toq o'rindagi elementlari yig'indisi: "< Download 383.47 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling