From 3586b439cab0f9b7e509fcb4cbeaac2048b9cdd6 Mon Sep 17 00:00:00 2001 From: RikuYokoo Date: Mon, 22 Mar 2021 18:26:43 +0900 Subject: [PATCH] =?UTF-8?q?=E8=AA=B2=E9=A1=8C5=E3=81=AE=E6=8F=90=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yokoo_5.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 yokoo_5.cpp diff --git a/yokoo_5.cpp b/yokoo_5.cpp new file mode 100644 index 0000000..e44abe0 --- /dev/null +++ b/yokoo_5.cpp @@ -0,0 +1,73 @@ +#include +#include + +using namespace std; + +class Cross_product{ +public: + Cross_product(); + Cross_product(int); + void ans_of_Cross_product(); + void output_anser(); + void output_xy(); +private: + vector x_component_of_vector; + vector y_component_of_vector; + vector anser_cross_product; +}; +Cross_product::Cross_product(){ + for(int i=0, j=5;i<3;i++, j+=2){ + int k=i+j; + x_component_of_vector.push_back((j+i)*(3+k)); + y_component_of_vector.push_back((j+k)*(3+i)); + } +} +Cross_product::Cross_product(int num){ + for(int i=0, k=4;i<3;i++,k*=3){ + x_component_of_vector.push_back((num)-(3+k)); + y_component_of_vector.push_back((num)-(3+i)); + } +} +void Cross_product::output_xy(){ + cout << "x={"; + for(int i=0;i<3;i++){ + cout << x_component_of_vector.at(i); + cout << " "; + } + cout << "}" << endl; + cout << "y={"; + for(int i=0;i<3;i++){ + cout << y_component_of_vector.at(i); + cout << " "; + } + cout << "}" << endl; +} +void Cross_product::ans_of_Cross_product(){ + for(int i=0, j=1,k=2;i<3;i++,k++,j++){ + anser_cross_product.push_back((x_component_of_vector.at(j)*y_component_of_vector.at(k))-(x_component_of_vector.at(k)*y_component_of_vector.at(j))); + if(i==0) + k=-1; + if(i==1) + j=-1; + } +} +void Cross_product::output_anser(){ + for(int i=0;i<3;i++){ + cout << anser_cross_product.at(i); + cout << " "; + } + cout << endl; +} + +int main(){ + Cross_product cross; + cross.output_xy(); + cross.ans_of_Cross_product(); + cross.output_anser(); + cout << endl; + Cross_product cross2(21); + cross2.output_xy(); + cross2.ans_of_Cross_product(); + cross2.output_anser(); + return 0; +}