2013-02-01から1ヶ月間の記事一覧

C++で2次元ベクトルクラスを作る

C++

ここでいうベクトルはstd::vectorではなく、2次元平面上の幾何ベクトルを意味します。 特徴は、a / b を外積にしている点です。これは当たり判定等で役立ちます。 #include <cmath> class Vector2 { public: double x, y; Vector2():x(0),y(0){ } Vector2(const Vec</cmath>…

C++でのCSVファイルの処理について

C++

色々あさってみて、最終的にこれが今一番しっくりきたので載せます。せっかくだし。 data.csv 10, 20, 30 hello, world, ! 12a, 23b, 34c main.cpp #include <iostream> #include <fstream> #include <string> #include <vector> using namespace std; int main(){ ifstream file("data.csv"); v</vector></string></fstream></iostream>…