Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl8e4;
- import java.util.Scanner;
- /**
- *
- * @author jose
- */
- public class Pl8e4 {
- private static final Scanner le=new Scanner(System.in);
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int l=parametrosl();
- int c=parametrosc();
- int v[][]=new int[l][c];
- prencher(v);
- System.out.println("Qual o numero que quer maior");
- int m=le.nextInt();
- valM(v,m);
- }
- private static int parametrosl(){
- int l;
- do{
- System.out.println("Quantas linhas tem o vetor");
- l=le.nextInt();
- }while(l<1);
- return l;
- }
- public static int parametrosc(){
- int c;
- do{
- System.out.println("Quantas colunas tem o vetor");
- c=le.nextInt();
- }while(c<1);
- return c;
- }
- public static void prencher(int v[][]){
- int p,num;
- for(int i=0;i<v.length;i++){
- for(int j=0;j<v[0].length;j++){
- do{
- System.out.println("Qual o numero para a linha "+(i+1)+" e coluna "+(j+1));
- num=le.nextInt();
- p=verificacao(v,num);
- }while(p!=-1);
- v[i][j]=num;
- }
- }
- }
- public static int verificacao(int v[][],int num){
- int q=2;
- for(int i=0;i<v.length;i++){
- for(int j=0;j<v[0].length;j++){
- if(num==v[i][j]){
- System.out.println("Numero repetido");
- return q;
- }
- }
- }
- return -1;
- }
- public static void valM(int v[][],int M){
- for(int i=0;i<v.length;i++){
- for(int j=0;j<v[0].length;j++){
- if(v[i][j]>M)
- System.out.println("A numero na linha "+i+" e na coluna "+j+" é maior que "+M+" tendo este o valor de "+v[i][j]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement