HW7.6
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); int[][] matrix1 = new int[3][3]; int[][] matrix2 = new int[3][3]; int[][] matrixSum = new int[3][3]; System.out.print("Enter matrix1: "); for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) matrix1[i][j] = input.nextInt(); System.out.print("Enter matrix2: "); for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) matrix2[i][j] = input.nextInt(); input.close(); System.out.println("The matrices are muliplied as follows"); int[][] matrixProduct = muliplyMatrix(matrix1, matrix2); System.out.println(matrix1[0][0] + " " + matrix1[0][1] + " " + matrix1[0][2] + " " + matrix2[0][0] + " " + matrix2[0][1] + " " + matrix2[0][2] + " " + matrixSum[0][0] + " " + matrixSum[0][1] + " " + matrixSum[0][2]); System.out.println(matrix1[1][0] + " " + matrix1[1][1] + " " + matrix1[1][2] + " * " + matrix2[1][0] + " " + matrix2[1][1] + " " + matrix2[1][2] + " = " + matrixSum[1][0] + " " + matrixSum[1][1] + " " + matrixSum[1][2]); System.out.println(matrix1[2][0] + " " + matrix1[2][1] + " " + matrix1[2][2] + " " + matrix2[2][0] + " " + matrix2[2][1] + " " + matrix2[2][2] + " " + matrixSum[2][0] + " " + matrixSum[2][1] + " " + matrixSum[2][2]); } public static int[][] muliplyMatrix(int[][] a, int[][] b) { int[][] outcomeMatrix = new int[3][3]; for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { outcomeMatrix[i][j] += a[i][j] * b[j][i]; } } return outcomeMatrix; } }
HW7.6的更多相关文章
- HW7.18
public class Solution { public static void main(String[] args) { int[][] m = {{1, 2}, {3, 4}, {5, 6} ...
- HW7.17
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.16
import java.util.Arrays; public class Solution { public static void main(String[] args) { int row = ...
- HW7.15
public class Solution { public static void main(String[] args) { double[][] set1 = {{1, 1}, {2, 2}, ...
- HW7.14
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.13
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.12
import java.util.Scanner; public class Solution { public static void main(String[] args) { double[] ...
- HW7.11
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.10
public class Solution { public static void main(String[] args) { int[][] array = new int[3][3]; for( ...
- HW7.9
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- Ehcache 整合Spring 使用页面、对象缓存(转载)
Ehcache在很多项目中都出现过,用法也比较简单.一般的加些配置就可以了,而且Ehcache可以对页面.对象.数据进行缓存,同时支持集群/分布式缓存.如果整合Spring.Hibernate也非常的 ...
- Java 程序检查远程服务器状态
通常我们以命令的方式判断远程服务器是否正常运行有两种方式,ping 或 telnet 一个远程端口.假设我们要检查的远程服务器都是 Linux 系统. 从 JDK 1.5 以后, InetAddres ...
- 使用rsyslog+loganalzey收集日志显示客户端ip
http://www.ituring.com.cn/article/128536 rsyslog localhost 转发 http://bigsec.net/one/tool/rsyslog.htm ...
- HDU4627+LCM
思路是想到了一些 不过愣是没敢写........... /* 题意:给定一个整数n(2 <= n <= 109),满足a+b=n并且[a,b]的最小公倍数最大. */ #include&l ...
- APK签名校验绕过
APK签名校验绕过 Android JNI 获取应用签名 android apk 防止反编译技术第一篇-加壳技术 android apk 防止反编译技术第五篇-完整性校验 利用IDA Pro反汇编程序 ...
- [译]C++书籍终极推荐
转载声明: 翻译仅以技术学习和交流为目的,如需转载请务必标明原帖链接. 来源:http://stackoverflow.com/questions/388242/the-definitive-c-bo ...
- 思科模拟器软件教程---教你如何划分Vlan
方法/步骤 1.打开Cisco Packet Tracer,点击[交换机],选择第三个图标2960交换机,按住鼠标左键拖动到工作区.这里有很多类型的交换机,但是我们比较常用的是这个. 2.我们选择[终 ...
- 网上图书商城项目学习笔记-036工具类之CommonUtils及日期转换器
1.CommonUtils.java package cn.itcast.commons; import java.util.Map; import java.util.UUID; import or ...
- MYSQL 优化建议
转自 http://coolshell.cn/articles/1846.html MYSQL 优化建议20条 1. 为查询缓存优化你的查询 大多数的MySQL服务器都开启了查询缓存.这是提高性最有效 ...
- Ubuntu 学习笔记
1. ubuntu开启root账号,设置分配很简单,只要为root设置一个root密码就行了: $ sudo passwd root 之后会提示要输入root用户的密码,连续输入root密码,再使 ...