当前位置:网站首页>Find the sum of simple types of matrices
Find the sum of simple types of matrices
2022-04-23 08:50:00 【Beauty of algorithm and programming】
1. introduction
adopt Python All kinds of functions and logical relationships can easily solve the problem of large amount of calculation compared with yourself .
2. problem describe
Give any m*n Matrix of size , Find the sum .
3. Algorithm description
First, we need to give the size of the variable specification matrix , Enter the specific value of the matrix through the keyboard and store it in a list , Calculate their sum according to the given matrix specification .
4. Conclusion
In this experiment , We need to use for Loop statement , And it's a cycle plus a cycle . In this experiment , Because there are multiple cycles , Pay attention to the indentation of each line of code , Different indents represent different meanings , The results are different .
Code list 1
| m, n = map(int, input().split()) a = [] for i in range(m): s = input() a.append([int(n) for n in s.split()]) for j in range(m): sum = 0 for k in range(n): sum += a[j][k] print(sum) |
Source of contribution : Deep learning and cultural tourism application laboratory (DLETA)
author : Wang Peng
Editor in chief : Ouyang
版权声明
本文为[Beauty of algorithm and programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230826083685.html
边栏推荐
猜你喜欢

The K neighbors of each sample are obtained by packet switching

Yangtao electronic STM32 Internet of things entry 30 step notes II. Cube ide download, installation, sinicization and setting

引用传递1

在sqli-liabs学习SQL注入之旅(第十一关~第二十关)

Chris LATTNER, father of llvm: the golden age of compilers

Enterprise wechat application authorization / silent login

洋桃电子STM32物联网入门30步笔记四、工程编译和下载

IDEA导入commons-logging-1.2.jar包

【58】最后一个单词的长度【LeetCode】

Valgrind and kcache grind use run analysis
随机推荐
Notes on 30 steps of introduction to Internet of things of yangtao electronics STM32 III. Explanation of new cubeide project and setting
RCC introduction of Hal Library
IDEA导入commons-logging-1.2.jar包
Valgrind and kcache grind use run analysis
关于cin,scanf和getline,getchar,cin.getline的混合使用
Virtual online exhibition - Online VR exhibition hall realizes 24h immersive exhibition viewing
xctf刷题小记
应纳税所得额
Complete binary search tree (30 points)
使用flask和h5搭建网站/应用的简要步骤
K210学习笔记(二) K210与STM32进行串口通信
Share the office and improve the settled experience
Kubernetes如何使用harbor拉去私有镜像
The K neighbors of each sample are obtained by packet switching
valgrind和kcachegrind使用運行分析
Whether the same binary search tree (25 points)
On time atom joins hands with oneos live broadcast, and the oneos system tutorial is fully launched
ESP32程序下载失败,提示超时
LLVM之父Chris Lattner:编译器的黄金时代
LeetCode_DFS_中等_1254. 统计封闭岛屿的数目