【java】矩阵相乘
来源:互联网 发布:sql判断count的值大于 编辑:程序博客网 时间:2024/05/21 11:06
import java.util.Scanner;public class pra4 {public static void main(String[] args){Scanner input = new Scanner(System.in);System.out.println("Enter matrix1: ");float [][]a = new float[3][3];for(int i = 0;i<3;i++){for(int j = 0;j<3;j++){a[i][j] = input.nextFloat();}}System.out.println("Enter matrix2: ");float [][]b = new float[3][3];for(int k = 0;k<3;k++){for(int j = 0;j<3;j++){b[k][j] = input.nextFloat();}}System.out.println("The matrices are multiplied as follows");float [][]c = new float[3][3];for(int h = 0;h<3;h++){for(int u = 0;u<3;u++){c[h][u] = 0;}}for(int h = 0;h<3;h++){for(int u = 0;u<3;u++){for(int w = 0;w<3;w++)c[h][u] += a[h][w]*b[w][u];}}for(int q = 0;q<3;q++)System.out.print(a[0][q]+" ");System.out.print(" ");for(int q = 0;q<3;q++)System.out.print(b[0][q]+" ");System.out.print(" ");for(int q = 0;q<3;q++)System.out.printf("%.2f",c[0][q]);System.out.print('\n');for(int q = 0;q<3;q++)System.out.print(a[1][q]+" ");System.out.print(" * ");for(int q = 0;q<3;q++)System.out.print(b[1][q]+" ");System.out.print(" = ");for(int q = 0;q<3;q++)System.out.printf("%.2f",c[1][q]);System.out.print('\n');for(int q = 0;q<3;q++)System.out.print(a[2][q]+" ");System.out.print(" ");for(int q = 0;q<3;q++)System.out.print(b[2][q]+" ");System.out.print(" ");for(int q = 0;q<3;q++)System.out.printf("%.2f",c[2][q]);}}
0 0
- 【java】矩阵相乘
- java实现矩阵相乘
- java 矩阵相乘
- Java实现矩阵相乘
- Java实现两个矩阵相乘
- 蓝桥杯-矩阵相乘(java)
- java 矩阵相乘,矩阵线性运算
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- 矩阵相乘
- memcpy实现
- 【java】矩阵相加
- 利用pysftp实现sqlite的远程访问
- 用OpenSceneGraph实现的NeHe OpenGL教程 - 第十一课
- 形象理解android电源管理wakelock状态
- 【java】矩阵相乘
- Android LBS中网络定位服务的实现方法
- 基于Android平台的手机卫士效果图
- ext panel的使用 以及ext.ajax.request的使用
- linux redis 安装配置, 以及redis php扩展
- 百度地图V2.3.5获取API key相关经验(android)
- JDBC之一:JDBC快速入门
- python unittest框架用后分享
- ext2、ext3、ext4、brtfs文件系统区别