Given a one-dimensional array that contains no more than 50 integers. Replace each element of the array with the sum of neighboring elements. If there are no neighboring elements, then the number is left unchanged. Here is the code:
import java.util.Scanner; class Laba5_1 { public static void main(String args[]) { Scanner input = new Scanner(System.in); int array[] = new int[10]; int aP[] = new int[10]; System.out.println("Введите элемент массива: "); for (int i = 0; i < 10; i++) { array[i] = input.nextInt(); } System.out.println("Введенный массив: "); for (int i = 0; i < 10; i++) { System.out.print(" " + array[i]); } System.out.println(); for (int i = 0; i < 10; i++) { if (i != 0 || i != 10) { int aP[j] = array[i - 1] + array[i + 1]; j++; } } System.out.println("Преобразованный массив: " + aP); } }
i != 0 || i != 10i != 0 || i != 10, I think ... - zRrr