功能实现
This commit is contained in:
parent
1722bc6cfe
commit
aae4fe2f26
1 changed files with 42 additions and 0 deletions
42
SoftwareDesign/Code/1-1c/main.cpp
Normal file
42
SoftwareDesign/Code/1-1c/main.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* @Author: iR
|
||||||
|
* @Date: 2022-03-11 20:22:54
|
||||||
|
* @LastEditors: iR
|
||||||
|
* @LastEditTime: 2022-03-12 14:13:14
|
||||||
|
* @FilePath: \Code\1-1c\main.cpp
|
||||||
|
* @Description:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 by iR, All Rights Reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../inc/matrix.hpp"
|
||||||
|
#include <stdio.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
double data[] = {1, 2, 3, 4};
|
||||||
|
Matrix<double> a(2, 2, data);
|
||||||
|
std::cout << "a" << std::endl
|
||||||
|
<< a.at(0, 0) << " " << a.at(1, 0) << std::endl
|
||||||
|
<< a.at(0, 1) << " " << a.at(1, 1) << std::endl;
|
||||||
|
std::cout << "+=" << std::endl;
|
||||||
|
|
||||||
|
Matrix<double> b(2, 2, data);
|
||||||
|
std::cout << "b" << std::endl
|
||||||
|
<< b.at(0, 0) << " " << b.at(1, 0) << std::endl
|
||||||
|
<< b.at(0, 1) << " " << b.at(1, 1) << std::endl;
|
||||||
|
std::cout << "Answer" << std::endl;
|
||||||
|
|
||||||
|
a += b;
|
||||||
|
std::cout << "a" << std::endl
|
||||||
|
<< a.at(0, 0) << " " << a.at(1, 0) << std::endl
|
||||||
|
<< a.at(0, 1) << " " << a.at(1, 1) << std::endl;
|
||||||
|
|
||||||
|
std::cout << "c=a+b" << std::endl;
|
||||||
|
Matrix<double> c = a + b;
|
||||||
|
std::cout << "Answer" << std::endl;
|
||||||
|
std::cout << "c" << std::endl
|
||||||
|
<< c.at(0, 0) << " " << c.at(1, 0) << std::endl
|
||||||
|
<< c.at(0, 1) << " " << c.at(1, 1) << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in a new issue