import java.util.Scanner; public class PJJJeden { public static void main(String[] args) { int[] tab = {1, 2, 3, 4, 5, 7, 8, 9, 10, 0}; Scanner sc = new Scanner(System.in); System.out.print("Wartość: "); int wart = sc.nextInt(); System.out.println("Wpisana wartość będzie sumą elementów tablicy: "); for(int i = 0; i < tab.length; i++){ for(int j = 0; j <tab.length; j++){ if ((tab[i] + tab[j] == wart)||(tab[j] + tab[i] == wart)){ System.out.println(tab[i] + " " + tab[j] );} } } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter