コード例 #1
0
ファイル: QuickSums.cpp プロジェクト: arshdeep/topcoder
void TEST(string numbers, int sum, int expected)
{
	clock_t start, end;
	double cpu_time_used;

	start = clock();
	QuickSums quickSums;

	int result = quickSums.minSums( numbers, sum);
	
	assert( result == expected );

	end = clock();
	cpu_time_used = ((double) (end - start));
	cout<<"Time taken : "<<cpu_time_used<<endl;
}
コード例 #2
0
int test3() {
    string numbers = "99999";
    int sum = 100;
    QuickSums* pObj = new QuickSums();
    clock_t start = clock();
    int result = pObj->minSums(numbers, sum);
    clock_t end = clock();
    delete pObj;
    int expected = -1;
    if(result == expected) {
        cout << "Test Case 3: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 3: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
コード例 #3
0
ファイル: 1000.cpp プロジェクト: 1code/algorithm-oeddyo
double test1() {
    string p0 = "1110";
    int p1 = 3;
    QuickSums * obj = new QuickSums();
    clock_t start = clock();
    int my_answer = obj->minSums(p0, p1);
    clock_t end = clock();
    delete obj;
    cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
    int p2 = 3;
    cout <<"Desired answer: " <<endl;
    cout <<"\t" << p2 <<endl;
    cout <<"Your answer: " <<endl;
    cout <<"\t" << my_answer <<endl;
    if (p2 != my_answer) {
        cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
        return -1;
    }
    else {
        cout <<"Match :-)" <<endl <<endl;
        return (double)(end-start)/CLOCKS_PER_SEC;
    }
}