2009-06-16から1日間の記事一覧

内積

C++

template <class T> struct vector2 { T x, y; vector2(const T& x, const T& y) : x(x), y(y) {} }; template <class T> T inner_product(const vector2<T>& v, const vector2<T>& u) { return v.x * u.x + v.y * u.y; } #include <iostream> int main() { vector2<float> v(-1, 1); vector2<float> u(1, -2)</float></float></iostream></t></t></class></class>…