Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) throws Exception {
  6.         Scanner wczytanie2 = new Scanner(System.in);
  7.  
  8.         //wczytujemy 3 inty i przypisujemy ich wartosci do zmiennych a,b, c
  9.         int a = wczytanie2.nextInt();
  10.         int b = wczytanie2.nextInt();
  11.         int c = wczytanie2.nextInt();
  12.         //wyspiujesz zmienne a b c
  13.         System.out.println(a + " " + b + " " + c);
  14.  
  15.         //tworzysz tablice dlugosci 3 i wrzucasz do niej zmienne a,b,c
  16.         int[] tab1 = new int[3];
  17.         tab1[0] = a;
  18.         tab1[1] = b;
  19.         tab1[2] = c;
  20.  
  21.         //tworzysz petle w ktorej
  22.         for (int e = 0; e < tab1.length; e++) {
  23.             //wrzucasz do tablicy nowe elementy, ktore wczytujesz z konsoli
  24.             tab1[e] = wczytanie2.nextInt();
  25.             //wypisujesz te elementy
  26.             System.out.println(tab1[e] + " ");
  27.         }
  28.  
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement