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


C++ BinaryHeap::makeEmpty方法代码示例

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


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

示例1: runSim

int runSim(int a1, int a2, int a3){
    BinaryHeap<Soldier> test;
    test.buildSoldiers(a2, a3);
    return test.events();
    test.makeEmpty();

}
开发者ID:ShoebRehman,项目名称:CS335-SpartanVPersianSimulation,代码行数:7,代码来源:Main.cpp

示例2: main


//.........这里部分代码省略.........

        cout << "Persians remaining: " << persian_Count << endl;

        sum_Persians = sum_Persians + persian_Count;
        soldier_count_Persians.push_back(persian_Count);

        cout << "The ID's of all our Spartans: " << endl;

        file << "Output for simulation: " << i << endl;
        file << "-----------------------" << endl;
        file << "Remaining soldiers: " << endl;
        file << "Spartans: " << spartan_Count << " Persians: " << persian_Count << endl;

        //printOutIDs(alive_Spartans, total_Spartans);
        cout << "The ID's of all our Persians: " << endl;
        //printOutIDs(alive_Persians, total_Persians);

        cout << "*****************************************************" << endl;
        cout << "******************THE WINNER IS..********************" << endl;
        if(spartan_Count == 0){
             cout << "The Persians are victorious!" << endl;
             numberOfPersianVictories++;

             file << "The Persians have won simulation: " << i << endl;

        }
        else{
             cout << "The Spartans are victorious!" << endl;
             numberOfSpartanVictories++;
            
             file << "The Spartans have won simulation: " << i << endl;
        }

        heap.makeEmpty();	
        spartan_Count = total_Spartans;
        persian_Count = total_Persians;
        alive_Spartans.clear();
        alive_Persians.clear();


        seconds_since_start = (double)(clock() - start)/CLOCKS_PER_SEC;
        cout << "This battle took: " << seconds_since_start << " seconds."  << endl;
        file << "Battle " << i << " took a total of: " << seconds_since_start << " seconds." << endl;
        time_Count.push_back(seconds_since_start);
        sum_Time += seconds_since_start;
        
        file << "------------------" << endl;
        
    }
    
    file << "~~~~~~~~~~~~~~~~~~~~~SIMULATIONS HAVE ENDED~~~~~~~~~~~~~~~~~~" << endl;

    cout << "The Spartans have won: " << numberOfSpartanVictories << " time(s)" << endl;
    cout << "The Persians have won: " << numberOfPersianVictories << " time(s)" << endl;
    
    spartan_Final_Average = arithMean(sum_Spartans, numberOfTimes);
    persian_Final_Average = arithMean(sum_Persians, numberOfTimes);
    time_Final_Average = arithMean(sum_Time, numberOfTimes);

    cout << "Average number of living Spartans: " << spartan_Final_Average << endl;
    cout << "Average number of living Persians: " << persian_Final_Average << endl;
    cout << "Average battle length: " << time_Final_Average << endl;

    omega_Spartan = standard_deviation(soldier_count_Spartans, numberOfTimes, spartan_Final_Average);
    omega_Persian = standard_deviation(soldier_count_Persians, numberOfTimes, persian_Final_Average);
    omega_Time = standard_deviation(time_Count, numberOfTimes, time_Final_Average);
开发者ID:jseuribe,项目名称:335_project3,代码行数:67,代码来源:sim300.cpp


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