本文整理汇总了C++中GeneralChess类的典型用法代码示例。如果您正苦于以下问题:C++ GeneralChess类的具体用法?C++ GeneralChess怎么用?C++ GeneralChess使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeneralChess类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
GeneralChess g;
vector<string> v{"-1000,1000", "-999,999", "-999,997"};
vector<string>ans = g.attackPositions(v);
for(int i=0; i<ans.size(); ++i)
{
cout<<ans[i]<<"\t";
}
return 0;
}
示例2: test31
int test31() {
vector<string> pieces = {"-3,0"};
GeneralChess* pObj = new GeneralChess();
clock_t start = clock();
vector<string> result = pObj->attackPositions(pieces);
clock_t end = clock();
delete pObj;
vector<string> expected = {"-5,-1", "-5,1", "-4,-2", "-4,2", "-2,-2", "-2,2", "-1,-1", "-1,1"};
if(result == expected) {
cout << "Test Case 31: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
return 0;
} else {
cout << "Test Case 31: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
return 1;
}
}
示例3: test3
int test3() {
vector<string> pieces = {"-1000,1000", "-999,999", "-999,997"};
GeneralChess* pObj = new GeneralChess();
clock_t start = clock();
vector<string> result = pObj->attackPositions(pieces);
clock_t end = clock();
delete pObj;
vector<string> expected = {"-1001,998"};
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;
}
}
示例4: test30
int test30() {
vector<string> pieces = {"42,5"};
GeneralChess* pObj = new GeneralChess();
clock_t start = clock();
vector<string> result = pObj->attackPositions(pieces);
clock_t end = clock();
delete pObj;
vector<string> expected = {"40,4", "40,6", "41,3", "41,7", "43,3", "43,7", "44,4", "44,6"};
if(result == expected) {
cout << "Test Case 30: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
return 0;
} else {
cout << "Test Case 30: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
return 1;
}
}