12. Boshiga qo‘yish usulidan foydalanib ro‘yhatda qo‘shni elementlari ayrimasi 72 dan kichik bo‘lgan elementni toping. Agar bunday elementlar ko‘p bo‘lsa, u holda ularning eng kattasini toping; agar bunday element mavjud bo‘lmasa – shunga mos ma’lumot chiqaring.
#include
using namespace std;
int Qidiruv(int arr[], int n)
{
int i = 0,h=0,m;
while (i{
if (abs(arr[i]-arr[i+2])<72){
return arr[i+1];
}
i = i++;
h = h++;
}
if (h>1){
m = max(arr[i]);
cout<<”Eng kattasi: “<
}
cout << "Bunday son mavjud emas!";
return 0;
}
int main()
{
int arr[]={},m;
cout<<"Elementlari sonini kiriting: ";
cin>>m;
for(int i=0; i
cout<
cin>>arr[i];
}
int n = sizeof(arr)/sizeof(arr[0]);
cout << "Bu element: "<< Qidiruv(arr,n);
return 0;
}
Do'stlaringiz bilan baham: |