710-20 guruh talabasi Saydirasulov Nozimjonning Malumotlar tuzilmasi va algoritmlash fanidan bajargan 2-lab topshirigi
12-variyant
public class Main {
public static void main(String[] args) {
System.out.print("Massiv elementlari sonini kiriting n = ");
int n = new Scanner(System.in).nextInt();
int[] arr = new int[n];
int max = 0;
for (int i = 0; i < arr.length; i++) {
System.out.print("arr[" + i + "] = ");
arr[i] = new Scanner(System.in).nextInt();
}
for (int i = 1; i < arr.length - 1; i++) {
if (Math.abs(arr[i + 1] - arr[i - 1]) < 72)
if (max < arr[i])
max = arr[i];
}
if (max == 0) {
System.out.println("bunday element yoq");
return;
}
System.out.println(max);
}
}
Do'stlaringiz bilan baham: |