2010-09-06から1日間の記事一覧

円周率

ぼーーーー( ゚ ρ ゚ ) #include <pstade/oven/generation.hpp> #include <pstade/oven/algorithm.hpp> #include <pstade/oven/regular.hpp> #include <cmath> #include <cstdio> struct generator { typedef double result_type; result_type operator()() const { a_ += 1.0; return a_; } generator() : a_(0.) {} private: mut…</cstdio></cmath></pstade/oven/regular.hpp></pstade/oven/algorithm.hpp></pstade/oven/generation.hpp>

0と1を次々と返すC++のコード

C++

0と1を次々返す方法 - When it’s ready. C++らしく書けばこうかな #include <iostream> struct switcher { switcher(bool p = true) : p_(!p) {} operator bool() { return p_ = !p_; } private: bool p_; }; int main() { switcher sw; std::cout << sw << std::endl;</iostream>…