kotlin 查找id

A transpose of a matrix is simply a flipped version of the original matrix.
We can transpose a matrix by switching its rows with its columns

矩阵转置只是原始矩阵的翻转形式。
我们可以通过切换矩阵的行和列来转置矩阵

Given a matrix, we have to find its transpose matrix.

给定一个矩阵,我们必须找到它的转置矩阵。

Example:

例:

    Input:
matrix:
[2, 3, 4, 5, 6]
[7, 8, 9, 0, 9]
Output:
Transpose Matrix :
[2, 7]
[3, 8]
[4, 9]
[5, 0]
[6, 9]

在Kotlin中寻找矩阵转置的程序 (Program to find transpose of a matrix in Kotlin)

package com.includehelp
import java.util.*
// Main function, Entry Point of Program
fun main(args: Array<String>) {
//variable of rows and col
val rows: Int
val column: Int
//Input Stream
val scanner = Scanner(System.`in`)
//Input no of rows and column
print("Enter the number of rows and columns of matrix : ")
rows   = scanner.nextInt()
column = scanner.nextInt()
//Create Array
val matrixA     = Array(rows) { IntArray(column) }
val transposeMatrix = Array(column) {IntArray(rows)}
//Input Matrix
println("Enter the Elements of First Matrix ($rows X $column} ): ")
for(i in matrixA.indices){
for(j in matrixA[i].indices){
print("matrixA[$i][$j]: ")
matrixA[i][j]=scanner.nextInt()
}
}
//print Matrix A
println("Matrix A : ")
for(i in matrixA.indices){
println("${matrixA[i].contentToString()} ")
}
//Transpose of Matrix
for(i in transposeMatrix.indices){
for(j in transposeMatrix[i].indices){
transposeMatrix[i][j]=matrixA[j][i]
}
}
//print Transpose Matrix
println("Transpose Matrix : ")
for(i in transposeMatrix.indices){
println("${transposeMatrix[i].contentToString()} ")
}
}

Output

输出量

Run 1:
Enter the number of rows and columns of matrix : 3
4
Enter the Elements of First Matrix (3 X 4} ):
matrixA[0][0]: 2
matrixA[0][1]: 3
matrixA[0][2]: 4
matrixA[0][3]: 5
matrixA[1][0]: 6
matrixA[1][1]: 7
matrixA[1][2]: 8
matrixA[1][3]: 9
matrixA[2][0]: 0
matrixA[2][1]: 1
matrixA[2][2]: 2
matrixA[2][3]: 3
Matrix A :
[2, 3, 4, 5]
[6, 7, 8, 9]
[0, 1, 2, 3]
Transpose Matrix :
[2, 6, 0]
[3, 7, 1]
[4, 8, 2]
[5, 9, 3]
----
Run 2:
Enter the number of rows and columns of matrix : 2
5
Enter the Elements of First Matrix (2 X 5} ):
matrixA[0][0]: 2
matrixA[0][1]: 3
matrixA[0][2]: 4
matrixA[0][3]: 5
matrixA[0][4]: 6
matrixA[1][0]: 7
matrixA[1][1]: 8
matrixA[1][2]: 9
matrixA[1][3]: 0
matrixA[1][4]: 9
Matrix A :
[2, 3, 4, 5, 6]
[7, 8, 9, 0, 9]
Transpose Matrix :
[2, 7]
[3, 8]
[4, 9]
[5, 0]
[6, 9]

翻译自: https://www.includehelp.com/kotlin/find-transpose-of-a-matrix.aspx

kotlin 查找id

kotlin 查找id_Kotlin程序查找矩阵的转置相关推荐

  1. kotlin 查找id_Kotlin程序在矩阵中查找偶数和奇数的频率

    kotlin 查找id Given a matrix, we have to find frequencies of even and odd numbers. 给定一个矩阵,我们必须找到偶数和奇数的 ...

  2. kotlin 查找id_Kotlin程序查找给定范围内的素数

    kotlin 查找id A prime number is a natural number that is greater than 1 and cannot be formed by multip ...

  3. kotlin 查找id_Kotlin程序查找立方体区域

    kotlin 查找id A cube has 6 square faces, if edges length is side. Then the area of each square is side ...

  4. kotlin 查找id_Kotlin程序查找等边三角形的区域

    kotlin 查找id Formula to find area of Equilateral Triangle: area = ( 1.73 × side × side)/4 查找等边三角形面积的公 ...

  5. kotlin 查找id_Kotlin程序查找平行四边形的区域

    kotlin 查找id Formula to find area of Parallelogram: area = base*height 查找平行四边形面积的公式: area = base * he ...

  6. kotlin 查找id_Kotlin程序查找Sphere的体积

    kotlin 查找id Formula to find volume of Sphere: volume =(4/3)*PI*r^3 查找球体体积的公式: volume =(4/3)* PI * r ...

  7. kotlin 查找id_Kotlin程序查找圆柱体区域

    kotlin 查找id A cylinder is a three-dimensional structure which has circular bases parallel to each ot ...

  8. kotlin 查找id_Kotlin程序查找Square区域

    kotlin 查找id Formula to find area of Square: area = side*side 查找Square面积的公式: area = side * side Given ...

  9. c语言方阵的转置程序,C程序查找矩阵的转置

    C程序查找矩阵的转置 在此示例中,您将学习在C语言编程中查找矩阵的转置. 要理解此示例,您应该了解以下C语言编程主题: 矩阵的转置是通过交换行和列而获得的新矩阵. 在此程序中,要求用户输入行数r和列数 ...

最新文章

  1. Windows7 64位机上Emgu CV2.4.2安装与配置
  2. LeetCode 426. Convert Binary Search Tree to Sorted Doubly Linked List--转换二叉树为双向链表--Java,C++,Python解法
  3. 【计算摄影】计算机如何学会欣赏照片的美感?
  4. Windows phone 8 学习笔记(4) 应用的启动
  5. 图Graph--最短路径算法(Shortest Path Algorithm)
  6. 【伙伴故事】智慧厨电接入华为云+HarmonyOS,你的未来厨房长这样
  7. 话里话外:谁才是流程的主人
  8. python 代码命令大全-用什么库写 Python 命令行程序(示例代码详解)
  9. 联通光纤服务器没有响应怎么办,联通光纤猫断线无法上网等问题不一样的解决方案...
  10. python计算单词长度_附加一个计算单词长度的列表
  11. Java通过mysql-connector-java-8.0.11连接MySQL Server 8.0遇到的问题
  12. 电脑技巧:电脑内存不足怎么办?看完你就会了!
  13. 当里皮也成过客,请善待国足主帅的继任者
  14. 基于JSP实现医院病历管理系统,程序员如何在工作中自我增值
  15. 如何查看电脑支持的最大内存是多少
  16. 记一次APP去壳破解重新打包
  17. 【exe4j】如何利用exe4j把java桌面程序生成exe文件
  18. JQuery效果动画
  19. Mandelbrot命令行实现
  20. 华硕T303UA Rev 3.3 60NB0C60-MB2140点位图FZ

热门文章

  1. VSCode设置ESLint语法检查
  2. 推荐40个简单的 jQuery 导航插件和教程【下篇】
  3. js将canvas保存成图片并下载
  4. css中px、em和rem的区别总结
  5. css类选择器类名覆盖优先级
  6. 简化软件操作,提升用户体验
  7. 2019 The 19th Zhejiang University Programming Contest
  8. 【转】MFC学习总结
  9. mysql5.7乱码_mysql5.7中解决中文乱码的问题
  10. 网站页面左右_广州网站优化的技巧是什么?