Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

codingfarm

LATEX 자동 행렬 생성기 본문

그리고/기타

LATEX 자동 행렬 생성기

scarecrow1992 2020. 10. 24. 01:17

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
#include<string>
#include<vector>
 
using namespace std;
 
int main(void) {
    int m, n;
    cin >> m >> n;
    vector<vector<int>> mat;
    mat.assign(m, vector<int>(n, 0));
 
 
    for (int row = 0; row < m; row++
        for (int col = 0; col < n; col++
            cin >> mat[row][col];
 
    string ret;
    ret = "\\begin{bmatrix}";
 
    for (int row = 0; row < m; row++) {
        for (int col = 0; col < n; col++) {
            ret += to_string(mat[row][col]);
 
            if (col != n - 1)
                ret += " &";
        }
 
        if (row != m - 1)
            ret += " \\\\";
    }
 
 
    ret += "\\end{bmatrix}";
    cout << ret << endl;
    return 0;
}
cs

 

matrix_creator.exe
0.10MB

 

사용 예

Comments