//Matrix multiplication import java.util.Scanner; public class Matrix
{
public static void main(String args[])
{
Scanner s= new Scanner(System.in);
int i,j,k; System.out.println("enter the value of n"); int n=s.nextInt(); int a[][]=new int[n][n]; int b[][]=new int[n][n]; int c[][]=new int[n][n]; System.out.println("enter the array elements of a:"); for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=s.nextInt();
}
}//end of a matrix System.out.println("enter the array elements of b:"); for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
b[i][j]=s.nextInt();
}
}//end of b matrix System.out.println("the result matrix is:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<n;k++)
{ c[i][j]+=a[i][k]*b[k][j]; }
}
} for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
System.out.print(+c[i][j]);
}System.out.println();
}
}//end of main
}//end of class
Chat with our AI personalities
class Array58
{
public static void main(String[] args)
{
int i,j,k;
int [][] a={{1,2,3},{4,5,6},{7,8,9}};
int [][] b={{9,8,7},{6,5,4},{3,2,1}};
int [][]c=new int[3][3];
for (i=0;i<a.length;i++)
{
for (j=0;j<a[i].length;j++)
{
System.out.print(a[i][j]+" ");
}
System.out.println(" ");
}
System.out.println(" ");
for (i=0;i<b.length;i++ )
{
for (j=0;j<b[i].length;j++)
{
System.out.print(b[i][j]+" ");
}
System.out.println(" ");
}
System.out.println(" ");
for(i=0;i<a.length;i++)
{
for(j=0;j<b.length;j++)
{
c[i][j]=0;
for(k=0;k<a.length;k++)
{
c[i][j]+=a[i][k]*b[k][j];
}
System.out.print(c[i][j]+" ");
}
System.out.println(" ");
}
}
}
Shashi 8010234944
import java.util.Scanner; public class Matrix
{
public static void main(String args[])
{
Scanner s= new Scanner(System.in);
int i,j,k; System.out.println("enter the value of n"); int n=s.nextInt(); int a[][]=new int[n][n]; int b[][]=new int[n][n]; int c[][]=new int[n][n]; System.out.println("enter the array elements of a:"); for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=s.nextInt();
}
}//end of a matrix System.out.println("enter the array elements of b:"); for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
b[i][j]=s.nextInt();
}
}//end of b matrix System.out.println("the result matrix is:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<n;k++)
{ c[i][j]+=a[i][k]*b[k][j]; }
}
} for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
System.out.println(+c[i][j]);
}
}
}//end of main
}//end of class
import java.io.*;
public class matrixmul
{
public static void main (String args[])
{
try
{
BufferedReader e = new BufferedReader(new InputStreamReader(System.in));
int m,n;
int c[][] = new int[3][3];
int b[][] = new int[3][3];
int d[][] = new int[3][3];
for ( m = 0 ; m < 3; m++ )
{
for (n = 0; n < 3 ;n++)
{
System.out.println("-- Enter A number in row# "+(m+1)+" & # "+(n+1)+" column --" );
c[m][n] = Integer.parseInt(e.readLine());
}
}
System.out.println(" ----- First Matrix ----");
for ( m = 0 ; m < 3; m++ )
{
for (n = 0; n < 3 ; n++)
{
System.out.print(c[m][n]);
}
System.out.println();
}
for ( m = 0 ; m < 3; m++ )
{
for (n = 0; n < 3 ;n++)
{
System.out.println("-- Enter A number in row# "+(m+1)+" & # "+(n+1)+" column --" );
b[m][n] = Integer.parseInt(e.readLine());
}
}
System.out.println(" ----- Second Matrix ----");
for ( m = 0 ; m < 3; m++ )
{
for (n = 0; n < 3 ; n++)
{
System.out.print(c[m][n]);
}
System.out.println();
}
for ( m = 0 ; m < 3; m++ )
{
for (n = 0; n < 3 ;n++)
{
d[m][n] = d[m][n]+(b[m][n]*c[m][n]);
}
}
System.out.println(" ----- Multiplication of above matrix ----");
for ( m = 0 ; m < 3; m++ )
{
for (n = 0; n < 3 ; n++)
{
System.out.print(" "+d[m][n]);
}
System.out.println();
}
}
catch (Exception e){}
}
}
Matrix Add
/* Program MAT_ADD.C
**
** Illustrates how to add two 3X3 matrices.
**
** Peter H. Anderson, Feb 21, '97
*/
#include <stdio.h>
void add_matrices(int a[][3], int b[][3], int result[][3]);
void print_matrix(int a[][3]);
void main(void)
{
int p[3][3] = { {1, 3, -4}, {1, 1, -2}, {-1, -2, 5} };
int q[3][3] = { {8, 3, 0}, {3, 10, 2}, {0, 2, 6} };
int r[3][3];
add_matrices(p, q, r);
printf("\nMatrix 1:\n");
print_matrix(p);
printf("\nMatrix 2:\n");
print_matrix(q);
printf("\nResult:\n");
print_matrix(r);
}
void add_matrices(int a[][3], int b[][3], int result[][3])
{
int i, j;
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
result[i][j] = a[i][j] + b[i][j];
}
}
}
void print_matrix(int a[][3])
{
int i, j;
for (i=0; i<3; i++)
{
for (j=0; j<3; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
}
import java.io.*;
class mat
{
protected static void main()throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader());
int a[][]=new int[10][10];
int b[][]=new int[10][10];
int c[][]=new int[10][10];
for(byte i=0;i<10;i++)
{
for(byte j=0;j<10;j++)
{
System.out.print("Enter the value of a[ "+i+" ][ "+j+"]: ");
a[i][j]=Integer.parseInt(in.readLine());
}
}
for(byte i=0;i<10;i++)
{
for(byte j=0;j<10;j++)
{
System.out.print("Enter the value of b["+i+" ][ "+j+" ]: ");
b[i][j]=Integer.parseInt(in.readLine());
c[i][j]=a[i][j]+b[i][j];
}
}
for(byte i=0;i<10;i++)
{
System.out.println();
for(byte j=0;j<10;j++)
{
System.out.print(c[i][j]+" ");
}
}
write a program draw circle and ellipse by using oval methods in java
Write a program that graphically demonstrates the shortest path algorithm
Yes, that's what JNI is good for.
Since the Java program is basically a text file, you can write it in any text editor (although using a Java IDE, or an IDE with support for Java, does give you certain advantages). Thus, you can use programs such as NotePad or NotePad++ to write the Java program. Using word processors such as MS-Word is problematic, because these insert additional codes. You would have to make sure you save the resulting file in the text format - give the "Save As" command, and choose a text format from the list.
A Program in Java that spawns multiple threads is called a multithreaded program in Java.