Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- int tab2[] = { 4, 3, 8, 1, 5 };
- int min = tab2[0];
- int max = tab2[0];
- for (int x = 0; x < tab2.length; x++) {
- // tab[x] = Integer.parseInt(JOptionPane.showInputDialog("Podaj liczbe: "));
- // suma+=tab[x];
- if (tab2[x] < min) {
- System.out.println("min");
- min = tab2[x];
- }
- if (tab2[x] > max) {
- System.out.println("max");
- max = tab2[x];
- }
- }
- System.out.println("Największa z podanych liczb to: " + max);
- System.out.println("Najmniejsza z podanych liczb to: " + min);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement