Created
January 2, 2022 06:18
-
-
Save hjroh0315/cfa8070bb045d918869f32dc443e605c to your computer and use it in GitHub Desktop.
변태같은 다차원벡터
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
template<int> | |
struct multivector; | |
template<> | |
struct multivector<1> | |
{ | |
vector<int> vec; | |
int& operator[](int n) | |
{ | |
return vec[n]; | |
} | |
}; | |
template<int d> | |
struct multivector | |
{ | |
vector<multivector<d-1>> vec; | |
void add_row(int n) | |
{ | |
if(n==0)return; | |
vec.push_back(multivector<d-1>()); | |
add_row(n-1); | |
} | |
multivector<d-1>& operator[](int n) | |
{ | |
return vec[n]; | |
} | |
}; | |
int main() | |
{ | |
multivector<2> mvec; | |
mvec.add_row(2); | |
mvec[1].vec.push_back(3); | |
cout << mvec[1][0] << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment