Maximum element in C ++ MTL vector

xiaoxiao2021-03-06  41

#include "mtl / mtl.h"

#include "mtl / utils.h"

#include "mtl / tinalg_vec.h"

Using namespace MTL;

Using namespace std;

// begin

TYPEDEF EXTERNAL_VEC vec;

// end

/ *

Sample Output

[5, -3, -4, 6, 0,]

Largest Element in the vector x is at location 3

* /

int

Main ()

{

// begin

Const int n = 5;

Float DX [] = {5.0, -3.0, -4.0, 6.0, 0.0};

VEC x (dx, n);

INT iMax = max_index (x);

// end

Print_vector (x);

Cout << "Largest Element in the vector x is at location"

<< iMax << endl;

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-53787.html

New Post(0)