3 Vector k elementidan l elementigacha bo’lgan elementlarning o’rtacha qiymatidan hisoblansin


Download 383.47 Kb.
Sana13.04.2023
Hajmi383.47 Kb.
#1350688
Bog'liq
2-Amaliyot ishi


2-Amaliyot
3)Vector k – elementidan l – elementigacha bo’lgan elementlarning o’rtacha qiymatidan hisoblansin.
#include
using namespace std;
vectora;
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;icout<<" vectorning "<>c;
a.push_back(c);}
cout<<"k - elementi l - elementini kiriting:";
cin>>k>>l;
for(int i=0;iif(f>=k&&f<=1){
s+=a[i];q++;}
cout<<"\n---------Natija----------\n\n ";
s/q;
cout<<"Javob: "<return 0;
}
}
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;
vectora;
int main(){
int n;
float max,l,f;
cout<<"Vector o'lchamini kiriting :";
cin>>n;
for(int i=0;icout<<"vektorning "<>l;
a.push_back(l);}
max=a[0];
for(int i=0;iif(max>a[i]){
max=a[i]; }}
cout<<" \n---------Natija------------\n\n ";
for(int i=0;if=a[i]/max;
cout<return 0;}

3) Vektor tоk o`rindagi elementlarini yig’indisi hisoblansin
#include
using namespace std;
vectora;
int main(){
int n,k=1;
float s=0,l;
cout<<"Vector o'lchamini kiriting :";
cin>>n;
for(int i=0;icout<<"vektorning "<>l;
a.push_back(l);}
for(int i=0;iif(k%2!=0){
s+=a[i]; }
k++;}
cout<<" \n---------Natija------------\n\n ";
cout<<"toq o'rindagi elementlari yig'indisi: "<return 0;}

Download 383.47 Kb.

Do'stlaringiz bilan baham:




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