当前位置: 首页>>代码示例>>C++>>正文


C++ Puzzle::CreatePuzzle方法代码示例

本文整理汇总了C++中Puzzle::CreatePuzzle方法的典型用法代码示例。如果您正苦于以下问题:C++ Puzzle::CreatePuzzle方法的具体用法?C++ Puzzle::CreatePuzzle怎么用?C++ Puzzle::CreatePuzzle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Puzzle的用法示例。


在下文中一共展示了Puzzle::CreatePuzzle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: return

int								main(int argc, char **argv)
{
    char Name = 'M';
    std::string taq = "TaquinA5_2.txt";
    if (argc == 3)
    {
        std::ifstream infile;
        infile.open(argv[2]);
        if (!infile.is_open())
        {
            std::cout << "Error: file <" << argv[2] << ">" << " not found" << std::endl;
            return (-1);
        }
        infile.close();
        taq = argv[2];
        FileLoader				F;
        std::string				S;
        Puzzle					P;
        SolutionGenerator		SG;
        short unsigned int**	Tab;
        clock_t					timeDeb, timeEnd;
        std::list<Puzzle>		OpenedList, ClosedList;
        int x = 0, y = 0, fg = -42;

        timeDeb = clock();
        DisplayLogo();
        F.LoadFile(taq.c_str(), S);
        std::istringstream		In(S);
        P.SetAlgo(Name);
        Tab = P.CreatePuzzle(S);
        std::list<Puzzle>::iterator FirstPuzzle;
        OpenedList.push_back(P);
        while (fg != 0 && !OpenedList.empty())
        {
            FirstPuzzle = OpenedList.begin();
            fg = Resume(FirstPuzzle, OpenedList, ClosedList, timeEnd);
            ProcessUp(FirstPuzzle, OpenedList, ClosedList);
            ProcessDown(FirstPuzzle, OpenedList, ClosedList);
            ProcessRight(FirstPuzzle, OpenedList, ClosedList);
            ProcessLeft(FirstPuzzle, OpenedList, ClosedList);

            (*FirstPuzzle).ClearListTab();
            ClosedList.push_back(*FirstPuzzle);
            OpenedList.erase(FirstPuzzle);
        }
        if (fg != 0)
            std::cout << "NO SOLUTION FOR THIS TAQUIN!!!" << std::endl;
        std::cout << "CLOSED LIST NUMBER OF CONTENTS	: \t\t[" << ClosedList.size() << "]"<< std::endl;
        std::cout << "TIME ELAPSED			: \t\t[" << static_cast<double>(timeEnd - timeDeb) << "] ms." << std::endl;
        ShowNbMoves();
        std::cout << "Cleaning..." << std::endl;
        Clean(OpenedList, ClosedList);
        std::cout << "Clean done" << std::endl;
    }
    return (0);
}
开发者ID:SouhaibDZ,项目名称:taquin42,代码行数:56,代码来源:main.cpp


注:本文中的Puzzle::CreatePuzzle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。