本文整理汇总了C++中CrazyComponents类的典型用法代码示例。如果您正苦于以下问题:C++ CrazyComponents类的具体用法?C++ CrazyComponents怎么用?C++ CrazyComponents使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CrazyComponents类的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;
}
}
示例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;
}
}