将一个字符串转换为Matrix

将一个字符串转换为Matrix

问题描述:

如何在C ++中将n个字节的字符串转换为方形矩阵?

是否有任何库(或)处理矩阵的头文件?

How to convert a string of n bytes into a square matrix in C++?
Are there any library (or) Header file(s) which deal with matrices?

https://www.google.co.uk/search?q=c%2B%2B+matrix&oq=c%2B%2B + matrix& aqs = chrome.0.0l4j61l2.8822j0& sourceid = chrome& ie = UTF-8 [ ^ ]。


您可能始终字符串的子集解释为方形矩阵。

假设你有一个 C -like字符串:

You may always interpret a subset of a string as a square matrix.
Suppose you have a C-like string:
char s[]="hello world";



您可以使用字符串的第一个 9 字符来定义 3x3 矩阵。

矩阵的M ij 项目( 0< = i< = 2 0< = j< = 2 )是字符串的 s [i * 3 + j] 字符。


you may use the first 9 characters of the string to define a 3x3 matrix.
Where the Mij item of the matrix (with 0<=i<=2, 0<=j<=2) is the s[i*3+j] character of the string.