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


C++ CrazyComponents::expectedProfit方法代码示例

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


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

示例1: test4

double test4() {
    int p0 = 10;
    string t1[] = { "", "", "", "", "", "", "", "", "", "" };
    vector <string> p1(t1, t1+sizeof(t1)/sizeof(string));
    int t2[] = { 142352, 2342, 34534, 2344, 12346, 7589, 79872, 973453, 96233, 34567 };
    vector <int> p2(t2, t2+sizeof(t2)/sizeof(int));
    int t3[] = { 12432, 2345, 3678, 456, 345, 457, 56758, 4564, 774, 34567 };
    vector <int> p3(t3, t3+sizeof(t3)/sizeof(int));
    CrazyComponents * obj = new CrazyComponents();
    clock_t start = clock();
    double my_answer = obj->expectedProfit(p0, p1, p2, p3);
    clock_t end = clock();
    delete obj;
    cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
    double p4 = 1269258.9999999998;
    cout <<"Desired answer: " <<endl;
    cout <<"\t" << p4 <<endl;
    cout <<"Your answer: " <<endl;
    cout <<"\t" << my_answer <<endl;
    if (p4 != my_answer) {
        cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
        return -1;
    }
    else {
        cout <<"Match :-)" <<endl <<endl;
        return (double)(end-start)/CLOCKS_PER_SEC;
    }
}
开发者ID:1code,项目名称:algorithm-oeddyo,代码行数:28,代码来源:1000.cpp

示例2: test3

double test3() {
    int p0 = 5;
    string t1[] = { "1", "2", "0", "" };
    vector <string> p1(t1, t1+sizeof(t1)/sizeof(string));
    int t2[] = { 4, 5, 6, 7 };
    vector <int> p2(t2, t2+sizeof(t2)/sizeof(int));
    int t3[] = { 0, 0, 0, 8 };
    vector <int> p3(t3, t3+sizeof(t3)/sizeof(int));
    CrazyComponents * obj = new CrazyComponents();
    clock_t start = clock();
    double my_answer = obj->expectedProfit(p0, p1, p2, p3);
    clock_t end = clock();
    delete obj;
    cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
    double p4 = 0.0;
    cout <<"Desired answer: " <<endl;
    cout <<"\t" << p4 <<endl;
    cout <<"Your answer: " <<endl;
    cout <<"\t" << my_answer <<endl;
    if (p4 != my_answer) {
        cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
        return -1;
    }
    else {
        cout <<"Match :-)" <<endl <<endl;
        return (double)(end-start)/CLOCKS_PER_SEC;
    }
}
开发者ID:1code,项目名称:algorithm-oeddyo,代码行数:28,代码来源:1000.cpp


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