Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package ciąg;
  7.  
  8. import javax.swing.JOptionPane;
  9.  
  10. /**
  11.  *
  12.  * @author s8582
  13.  */
  14. public class Main {
  15.  
  16.     /**
  17.      * @param args the command line arguments
  18.      */
  19.     public static void main(String[] args) {
  20.         int ilosc = Integer.parseInt(JOptionPane.showInputDialog("Podaj ilość elementów"));
  21.         int najwieksza = 0;
  22.         for(int i=0; i<ilosc; i++) {            
  23.             int liczba = Integer.parseInt(JOptionPane.showInputDialog("Podaj liczbę nr"+(i+1)));
  24.             if(i==0) {
  25.                 najwieksza = liczba;
  26.             } else if(liczba>najwieksza) {
  27.                 najwieksza = liczba;
  28.             }            
  29.         }
  30.         JOptionPane.showMessageDialog(null, "Największa liczba to: "+najwieksza);
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement