void Seeker::seekPermutations() { unsigned long long int N = 0; double duration, start = clock(); unsigned long long int TOTAL = countTotal(_v, _kp, _km); bool isFound = false; while (_sequence[0] != 2) { N++; duration = (clock() - start) / (double)CLOCKS_PER_SEC; if (duration > SHOW_TIME) { cout << "Done: " << (N*100.)/TOTAL <<"%" << endl; start = clock(); writeTEMP(); printSeq(_sequence, _v, "tmp"); } if (isTP(_sequence, _v)) { writeSeq2File(); printSeq(_sequence, _v, "FIND! "); isFound = true; break; } else { nextPermute(_sequence, _v); } } if (!isFound) { writeSeq2File("THERE ARE NO"); } }
//--------------------------------------------------------------------- // ファイルの総数を数える //--------------------------------------------------------------------- void countTotal(const kjm::_tstring& path) { kjm::folderInfo fi(path); // 中のファイルを数に加える g_totalCount += fi.getFiles().size(); _tcout << _T("総ファイル数 : ") << g_totalCount << _T("\r"); // サブフォルダを再帰処理 std::vector<kjm::folderInfo> folders = fi.getSubFolders(); for (std::vector<kjm::folderInfo>::iterator i = folders.begin(); i != folders.end(); i++) { countTotal(i->getFullPath()); } }
//--------------------------------------------------------------------- // プログラムスタート //--------------------------------------------------------------------- int _tmain(int argc, TCHAR** argv) { SET_UNICODE_MODE; // コンソールでの多言語出力に対応 kjm::optionInfoList opts; opts.push_back(kjm::optionInfo(_T("help"), _T("?"), kjm::no_argument)); opts.push_back(kjm::optionInfo(_T("version"), _T("v"), kjm::no_argument)); opts.push_back(kjm::optionInfo(_T("fast"), _T("f"), kjm::no_argument)); kjm::cmdLine cl; cl.parse(argc, argv, opts); if (cl.hasOption(_T("version"))) { version(); return 0; } else if (cl.hasOption(_T("help"))) { usage(); return 0; } else if (cl.get_argCount() != 1) { usage(); return 1; } int exitCode = -1; // ディスクのセクタサイズを取得 DWORD bytesPerSector = 0; if (GetDiskFreeSpace(cl.get_argument(0).c_str(), NULL, &bytesPerSector, NULL, NULL)) { _tcout << kjm::util::sprintf_str(_T("1セクタ当たりのバイト数: %d バイト"), bytesPerSector) << std::endl; // ファイルの総数を数えておく g_totalCount = 0; countTotal(cl.get_argument(0)); _tcout << std::endl; exitCode = readCheck(cl.get_argument(0), bytesPerSector, cl.hasOption(_T("fast")) ? true : false); } else { DWORD dwError = GetLastError(); _tcerr << kjm::util::sprintf_str(_T("'%s'のセクタサイズが取得できません。error %u: %s"), cl.get_argument(0).c_str(), dwError, kjm::util::formatMessageBySystem(dwError).c_str()) << std::endl; exitCode = -1; } return exitCode; }
int main() { int EV_current; int EV_count; int EV_total; struct EV_LameStruct * EV_digits; EV_digits = (struct EV_LameStruct*)malloc(sizeof(struct EV_LameStruct)); EV_count = 0; EV_digits->EV_one = 0; EV_digits->EV_two = 0; EV_digits->EV_three = 0; EV_digits->EV_four = 0; EV_digits->EV_five = 0; EV_digits->EV_six = 0; EV_digits->EV_seven = 0; EV_digits->EV_eight = 0; EV_digits->EV_nine = 0; scanf("%d", &EV_current); while ((EV_current!=0)) { if ((EV_current==1)) { EV_digits->EV_one = (EV_digits->EV_one+1); } else { if ((EV_current==2)) { EV_digits->EV_two = (EV_digits->EV_two+1); } else { if ((EV_current==3)) { EV_digits->EV_three = (EV_digits->EV_three+1); } else { if ((EV_current==4)) { EV_digits->EV_four = (EV_digits->EV_four+1); } else { if ((EV_current==5)) { EV_digits->EV_five = (EV_digits->EV_five+1); } else { if ((EV_current==6)) { EV_digits->EV_six = (EV_digits->EV_six+1); } else { if ((EV_current==7)) { EV_digits->EV_seven = (EV_digits->EV_seven+1); } else { if ((EV_current==8)) { EV_digits->EV_eight = (EV_digits->EV_eight+1); } else { EV_digits->EV_nine = (EV_digits->EV_nine+1); } } } } } } } } scanf("%d", &EV_current); } printf("%d\n",countTotal(EV_digits)); printRecursive(convertBinary(1), EV_digits->EV_one); printRecursive(convertBinary(2), EV_digits->EV_two); printRecursive(convertBinary(3), EV_digits->EV_three); printRecursive(convertBinary(4), EV_digits->EV_four); printRecursive(convertBinary(5), EV_digits->EV_five); printRecursive(convertBinary(6), EV_digits->EV_six); printRecursive(convertBinary(7), EV_digits->EV_seven); printRecursive(convertBinary(8), EV_digits->EV_eight); printRecursive(convertBinary(9), EV_digits->EV_nine); return 0; }