/****************************************************************************** バグベアード -bugbeard- サンプル "profile.cpp" ソースファイル Coded by Wraith in Sep 16, 2008. ******************************************************************************/ /////////////////////////////////////////////////////////////////////////////// // // includes // #include #include /////////////////////////////////////////////////////////////////////////////// // // [BUG]bugbeard // #if !defined(NDEBUG) #define BUG_EVIL_CONTRACT // "悪魔の契約" #endif #if defined(BUG_EVIL_CONTRACT) # define BUG_DEFINE_GLOBAL_LOGGER new bugbeard::bug_tree_logger(new bugbeard::bug_file_writer("trace.log")) // "trace.log" へツリー形式の出力を行うロガーの定義 # define BUG_DEFINE_GLOBAL_PROFILER new bugbeard::bug_tsv_profiler(new bugbeard::bug_file_writer("profile.tsv"), new bugbeard::bug_file_writer("coverage.tsv")) // "profile.tsv" へプロファイル結果の出力を、"coverage.tsv" へカバレッジ測定結果の出力を行うプロファイルロガーの定義 # define BUG_STATEMENT_HACK // ステートメントハックの設定 # include "bug.h" // ステートメントハックを有効にする為、再度 include #endif /////////////////////////////////////////////////////////////////////////////// // // user codes // // // 素因数分解 // void factorize(int number) { printf("%d = ", number); int current = number; if (1 < current) { int p = 2; int pn = 0; int inc = 1; while(1 < current) { if (current %p) { if (pn) { printf("%d", p); if (1 < pn) { printf("^%d", pn); } printf(" * "); pn = 0; } p += inc; // [BUG]値のログ出力 BUG_puts(BUG_VAL(p)); inc = 2; } else { current /= p; // [BUG]値のログ出力 BUG_puts(BUG_VAL(current)); ++pn; // [BUG]値のログ出力 BUG_puts(BUG_VAL(pn)); } } printf("%d", p); if (1 < pn) { printf("^%d", pn); } } else { printf("%d", current); } printf("\n"); return; } // // スタートアップ // int main(int argc, char * args[]) { for(int i = 1; i < argc; ++i) { factorize(atoi(args[i])); } return EXIT_SUCCESS; } /****************************************************************************** □■□■ Wraith the Trickster □■□■ ■□■□ 〜I'll go with heaven's advantage and fool's wisdom.〜 ■□■□ ******************************************************************************/