Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MaiorColuna {
  4. public static void main(String[] args) {
  5. Scanner in = new Scanner(System.in);
  6.  
  7. int[][] matriz = new int[5][3];
  8. for (int i = 0; i < 5; i++) {
  9. for(int j = 0; j < 3; j++) {
  10. matriz[i][j] = in.nextInt();
  11. }
  12. }
  13.  
  14. int maior;
  15. for (int i = 0; i < 3; i++) {
  16. maior = -100000;
  17. for(int j = 0; j < 5; j++) {
  18. if (matriz[j][i] > maior) {
  19. maior = matriz[j][i];
  20. }
  21. }
  22. System.out.printf("Maior da coluna %d é: %d\n", i+1, maior);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement