Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. package pl8e4;
  2. import java.util.Scanner;
  3. /**
  4. *
  5. * @author jose
  6. */
  7. public class Pl8e4 {
  8.  
  9. private static final Scanner le=new Scanner(System.in);
  10. /**
  11. * @param args the command line arguments
  12. */
  13. public static void main(String[] args) {
  14. int l=parametrosl();
  15. int c=parametrosc();
  16. int v[][]=new int[l][c];
  17. prencher(v);
  18. System.out.println("Qual o numero que quer maior");
  19. int m=le.nextInt();
  20. valM(v,m);
  21. }
  22. private static int parametrosl(){
  23. int l;
  24. do{
  25. System.out.println("Quantas linhas tem o vetor");
  26. l=le.nextInt();
  27. }while(l<1);
  28. return l;
  29. }
  30. public static int parametrosc(){
  31. int c;
  32. do{
  33. System.out.println("Quantas colunas tem o vetor");
  34. c=le.nextInt();
  35. }while(c<1);
  36. return c;
  37. }
  38.  
  39. public static void prencher(int v[][]){
  40. int p,num;
  41. for(int i=0;i<v.length;i++){
  42. for(int j=0;j<v[0].length;j++){
  43. do{
  44. System.out.println("Qual o numero para a linha "+(i+1)+" e coluna "+(j+1));
  45. num=le.nextInt();
  46. p=verificacao(v,num);
  47. }while(p!=-1);
  48. v[i][j]=num;
  49. }
  50. }
  51. }
  52.  
  53. public static int verificacao(int v[][],int num){
  54. int q=2;
  55. for(int i=0;i<v.length;i++){
  56. for(int j=0;j<v[0].length;j++){
  57. if(num==v[i][j]){
  58. System.out.println("Numero repetido");
  59. return q;
  60. }
  61. }
  62. }
  63. return -1;
  64. }
  65. public static void valM(int v[][],int M){
  66. for(int i=0;i<v.length;i++){
  67. for(int j=0;j<v[0].length;j++){
  68. if(v[i][j]>M)
  69. System.out.println("A numero na linha "+i+" e na coluna "+j+" é maior que "+M+" tendo este o valor de "+v[i][j]);
  70. }
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement