2) 14. X(N) massiv berilgan. Uning juft indeksli elementlarni Z massivga ko‘chirib yozing. Z massivdagi maksimal va minimal elementlarining o‘rnini o‘zaro almashtiring.
#include
using namespace std;
int main() {
int x[20]= {2,6,19,5,7,3,6,4,9,85,35,10};
int z[10];
int k=0;
for(int i=0 ; i<12; i++) {
if(i%2==1) {
z[k++]=x[i];
}
}
int max=z[0],min=z[0],max_i,min_i;
cout<<"Z massivning daslabki ko'rinishi : ";
for(int i=0 ; icout<if(z[i]>max) {
max=z[i];
max_i=i;
}
if(z[i]min=z[i];
min_i=i;
}
}
cout<swap(z[max_i],z[min_i]);
for(int i=0 ; i cout<}
3) 14float B[n][n] matrisani tasodifiy sonlar bilan to’ldiring, berilgan 6 va 3 ga karrali elementlarni joylashgan o’rnini toping
#include
#include #include using namespace std;
int main()
{
int length;
cout<<"Massiv uzunligini kiriting : ";
cin>>length;
float a[length];
for(int i=0; ia[i] = rand()%10;
cout<}
int index = 0;
for(int i=0; iif((int)a[i]%3==0 && (int)a[i]%6==0){
index = i;
}
}
cout<<"Joylashgan o`rni : "<return 0;
}