Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class II30012014 {
- private static Scanner in = new Scanner(System.in);
- public static double[][] lerMatriz(int i, int j){
- double[][] mat = new double[i][j];
- for( i=0;i<mat.length;i++){
- for(j=0;j<mat[0].length;j++){
- System.out.print("MAT["+i+"]["+j+"]=");
- mat[i][j]=in.nextDouble();
- }
- }
- return mat;
- }
- public static void listarMatriz(double[][] m){
- for(int i=0;i<m.length;i++){
- for(int j=0;j<m[0].length;j++){
- System.out.print(m[i][j]);
- }
- System.out.println();
- }
- }
- public static int[] lerVector(int n){
- int[] vec = new int[n];
- for(n=0;n<vec.length;n++){
- System.out.print("VEC["+n+"]=");
- vec[n]=in.nextInt();
- }
- return vec;
- }
- public static void listarVector(int[] v){
- for(int i=0;i<v.length;i++){
- System.out.println(v[i]);
- }
- }
- public static void listarVector(double[] v){
- for(int i=0;i<v.length;i++){
- System.out.println(v[i]);
- }
- }
- public static double[] calcularProduto(double[][] mat, int vec[]){
- double[] mult = new double[vec.length];
- for(int i=0;i<vec.length;i++){
- mult[i]=(double) vec[i]*mat[i][mat[0].length-i-1];
- }
- return mult;
- }
- public static double mimMax(double[][] mat){
- double maxglobal=mat[0][0],maxlinha,minglobal=mat[0][0],minlinha;
- for(int i=0;i<mat.length;i++){
- maxlinha=mat[i][0];
- minlinha=mat[i][0];
- for(int j=1;j<mat[0].length;j++){
- minlinha=(mat[i][j]<minlinha)?mat[i][j]:minlinha;
- maxlinha=(mat[i][j]>maxlinha)?mat[i][j]:maxlinha;
- }
- if(maxlinha==maxglobal && minlinha<minglobal)
- minglobal=minlinha;
- if(maxlinha>maxglobal){
- maxglobal=maxlinha;
- minglobal=minlinha;
- }
- }
- return minglobal;
- }
- public static void main(String[] args) {
- System.out.print("Comprimento:");
- int n=in.nextInt();
- System.out.println("<<PREENCHER VECTOR>>");
- int[] v1=lerVector(n);
- System.out.println("<<PREENCHER MATRIZ>>");
- double[][] mat = lerMatriz(n,n);
- System.out.println("<<PRODUTO MATRIZ*VEC>>");
- listarVector(calcularProduto(mat,v1));
- System.out.println("Minimo do Maximo:"+ mimMax(mat));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement