Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * r1,c2--Final Output
- * r2,c1--Condition
- */
- package helloworld;
- import java.io.*;
- import java.util.Scanner;
- /**
- * @author pradeep_7
- */
- public class Helloworld {
- public static void main(String[] args)throws IOException {
- Scanner hello = new Scanner(System.in);
- int r1,c1,r2,c2,i,j = 0,k;
- System.out.println("1St Matrix Row AND Column");
- r1=hello.nextInt();
- c1=hello.nextInt();
- System.out.println("2nd Matrix Row and Column");
- r2=hello.nextInt();
- c2=hello.nextInt();
- int[][] a = new int[30][30];
- int[][] b =new int[30][30];
- int[][] c = new int[30][30];
- //Reading 1st Matrix Machaaa
- System.out.println("1st Matrix Input");
- for(i=0;i<r1;i++)
- for(j=0;j<c1;j++)
- a[i][j]=hello.nextInt();
- //Reading Second Matrix Machaa
- System.out.print("2nd Matrix Input\n");
- for(i=0;i<r2;i++)
- for(j=0;j<c2;j++)
- b[i][j]=hello.nextInt();
- //Finally Loveda LO Logi****
- for(i=0;i<r1;i++)
- for(j=0;j<c2;j++)
- // c[i][j]=0;
- for(k=0;k<c1;k++)
- c[i][j]=c[i][j]+a[i][k]*b[k][j];
- //Printting Fasak
- for(i=0;i<r1;i++)
- for(j=0;j<c2;j++)
- System.out.print(" "+c[i][j]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement