码迷,mamicode.com
首页 > 编程语言 > 详细

C++常用速查

时间:2019-12-23 22:32:10      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:nts   int   name   map   str   time   pac   into   end   

int main()
{
    int arr[2][5] =
    {
        {1,8,12,20,25},
        {5,9,13,24,26}
    };
}
void f(double p[][10]) {
}
#include <Eigen/Dense>
#include <iostream>
using namespace std;
int main()
{
  Eigen::MatrixXf m(3,3);
  m << 1,2,3,
       4,5,6,
       7,8,9;
  cout << "Here is the matrix m:" << endl << m << endl;
  cout << "2nd Row: " << m.row(1) << endl;
  m.col(2) += 3 * m.col(0);
  cout << "After adding 3 times the first column into the third column, the matrix m is:\n";
  cout << m << endl;
Matrix3f m;
m << 1, 2, 3,
     4, 5, 6,
     7, 8, 9;
std::cout << m;
MatrxXd M = MatrixXd::Zero(50,50);
//矩阵转数组
double* test = M.data();
//数组转矩阵
Map<MatrixXd>tM(test, 50, 50);
MatrixXd M = MatrixXd::Zero(5, 5);
ofstream fout("test.txt");
fout << M;
fout.close();
#include<iostream>
int main()
{
    int a[4] = {0,1,2,3};
    int b[4];
    std::copy(a, a+4, b);
    b[3] = 5;
    std::cout << "a3 =" << a[3] << std::endl << "b3 =" << b[3] << std::endl;

    int c[4] = {0,1,2,3};
    int *d = c;
    d[3] = 5;
    std::cout << "c3 =" << c[3] << std::endl << "d3 =" << d[3] << std::endl;
    return 0;
}
double x[] = { .0, .1, .2, .3, .4 };
// Iterate through all elements
for (auto d : x)
{
    std::cout << d << std::endl;
}

C++常用速查

标签:nts   int   name   map   str   time   pac   into   end   

原文地址:https://www.cnblogs.com/yaos/p/12088053.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!