第6章_数组_编程练习_Exercise6_25(二维数组的相乘)
来源:互联网 发布:黎明三角洲淘宝店铺 编辑:程序博客网 时间:2024/04/30 01:57
/**
*两个二维数组的想相乘;
*这个两个二维数组要求行数,类型相等
*/
public class Exercise6_25 {
static int[][] arr ;
public static void main(String[] args){
int[][] a = {
{1,2,3},
{4,5,6},
{7,8,9}
};
int[][] b = {
{11,12,13},
{24,25,26},
{37,38,39}
};
System.out.println("数组相乘的结果:");
int[][] result = getArray(a, b);
for(int i = 0; i < result.length; i++){
for(int j = 0; j< result[i].length; j++){
System.out.print( result[i][j] + " ");
}
System.out.println();
}
}
public static int[][] getArray(int[][] a, int[][] b){
//一定要给arr分配空间,不然就会出现空指针异常
arr = new int[a.length][a[1].length];
for(int i = 0; i < a.length; i++){
for(int j = 0; j < a[i].length; j++){
arr[i][j] = a[i][j] * b[i][j];
}
}
return arr;
}
}
- 第6章_数组_编程练习_Exercise6_25(二维数组的相乘)
- 第6章_数组_编程练习_Exercise6_5
- 第6章_数组_编程练习_Exercise6_19(成绩排名)
- Day6_c语言_二维数组练习
- 二维数组练习05_计算鞍点
- 二维数组练习19_肿瘤检测
- 二维数组练习18_肿瘤面积
- 二维数组练习25_螺旋加密
- 二维数组练习17_最好的草
- 二维数组练习22_神奇的幻方
- JACK_C#_二维数组
- 红皮书c#高级编程(第6版)_第5章_数组
- C++_二维数组的简单举例
- 03_二维数组的查找
- 第5章_数组
- 二维数组练习03_计算矩阵边缘元素之和
- 二维数组练习13_图像模糊处理
- 5-二维数组_练习_字符串处理函数_指针
- c# 请求需要cookie支持的页面(保持请求的cookie)
- sed行对象【列表】和单个字符对象【替换】
- iphone关于self.用法的一些总结
- 第6章_数组_编程练习_Exercise6_19(成绩排名)
- python 处理字符ASICII码
- 第6章_数组_编程练习_Exercise6_25(二维数组的相乘)
- 将m个苹果放入n个盘子的问题
- javascript中替换表单中的全角字符为半角字符
- 查杀木马 QQ电脑管家 vs. 金山卫士
- Linux 防火墙
- CPU 调度
- JSTL1.1函数标签库(functions)如fn:length
- 微普之行--感怀
- 自定义类似于listView中Item背景