“odwrotna tablica Java” Kod odpowiedzi

odwrotna tablica Java

//With Commons.Lang, you could simply use

ArrayUtils.reverse(int[] array)

// For reversing subarray
ArrayUtils.reverse(int[] array,int startIndexInclusive, int endIndexExclusive)


Spotless Shark

Tablica odwrotna w Javie

        int[] xr = {1, 2, 3, 4, 5};

        System.out.print("[");
        for (int i = xr.length - 1; i >= 0; i--) {
            System.out.print(xr[i] + ", ");
        }
        System.out.println("\b\b]");
    }
Chathumal Sangeeth

Odwrotna tablica Java

import java.util.*;
import java.util.stream.Collectors;

int[] array = new int[] {23, 54, 12};
List<Integer> list = Arrays.stream(array).boxed().collect(Collectors.toList());
Collections.reverse(list);
array = list.stream().mapToInt(x -> x).toArray();
//array = [12,54,23]
Cheerful Cowfish

Tablica odwrotna Java

public void reverseArray(int[] arr) {
	int len = arr.length;
    int left = 0, right = len - 1 - left;
    while (left < right) {
        swap(arr, left, right);
        left++;
        right--;
    }
}
    
private void swap(int[] arr, int left, int right) {
    int tmp = =arr[left];
    arr[left] = arr[right];
    arr[right] = tmp;
}
Dlulu Dlala

Java odwraca tablicę

// Algorithm
wide_floating_point e() {
  unsigned n = 33;
  my_uint128 num = 1;
  my_uint128 den = 1;
  for (unsigned i=1; i <= n; i++) {
    num = num*i + 1;
    den = den*i;
  }
  return (wide_floating_point) num/fact;
}
Gregory M.

Tablica odwrotna Java

WWWWW-
S---W-
W-W-W-
W-W---
E-W-W-
WWWWW-
Uninterested Unicorn

Odpowiedzi podobne do “odwrotna tablica Java”

Pytania podobne do “odwrotna tablica Java”

Więcej pokrewnych odpowiedzi na “odwrotna tablica Java” w Java

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu