fork(1) download
  1. import java.util.*;
  2.  
  3. class Ideone
  4. {
  5. public static void main (String[] args)
  6. {
  7. Scanner sc = new Scanner(System.in);
  8. int maior1 = 0,
  9. maior2 = 0;
  10.  
  11. for(int i = 0; i < 5; i++) {
  12. System.out.println(" Digite nĂºmeros:");
  13. int num = sc.nextInt();
  14. if(num > maior1) {
  15. maior2 = maior1;
  16. maior1 = num;
  17. } else if(num > maior2) {
  18. maior2 = num;
  19. }
  20. }
  21. System.out.println(maior1 + " - " + maior2);
  22. }
  23. }
  24.  
Success #stdin #stdout 0.14s 321280KB
stdin
1
4
2
5
3
stdout
 Digite números:
 Digite números:
 Digite números:
 Digite números:
 Digite números:
5 - 4