用伪代码迭代 M x N 矩阵?
好吧,由于一些错误,我无法发布代码,所以我将对你们进行伪代码。请用代码和数学来回答。我的数学很糟糕,试图通过代码计算出数学对我来说是一项不可能完成的任务。
我的伪代码仅使用数字和字母,这将形成一个 2x2 矩阵,但我希望能够以这种方式迭代 m × n 矩阵。我只是认为从特定(无变量)到一般(包含变量)更容易。
Letter a, letter b; number 1, number 2 ==>
Letter a id=1, letter b id=1 |
number 1 id=1, number 2 id=2 |
Letter_by_Number 1by1, Letter_by_Number 1by2, Letter_by_Number 2by1, Letter_by_Number 2by2
谁能告诉我如何在 C++、Python、PHP 的 SimpleXML 或 XSL 中执行此操作?如果我能用这些语言中的任何一种来记下数学,我想我就能弄清楚其他一切。
Well, I can't post code because of some bug, so I'm going to pseudocode you guys. Please, respond with code and math. I am terrible at math, and trying to figure math out via code is an impossible task for me.
My psuedocode uses only numbers and letters, which will form a 2x2 matrix, but I want to be able to iterate across m by n matrices in this fashion. I just think that it's easier to go from specific (no variables) to general (variable-inclusive).
Letter a, letter b; number 1, number 2 ==>
Letter a id=1, letter b id=1 |
number 1 id=1, number 2 id=2 |
Letter_by_Number 1by1, Letter_by_Number 1by2, Letter_by_Number 2by1, Letter_by_Number 2by2
Can anyone tell me how to do this in C++, Python, PHP's SimpleXML, or XSL? If I can get the math down in any of these languages, I think I can figure everything else out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西吗?
结果:
Something like this?
Results:
您只想迭代一个二维数组。在伪代码中你会做类似的事情:
You just want to iterate through a 2-dimensional array. In pseudocode you'd do something like: