本文整理汇总了C++中Pair::setMatches方法的典型用法代码示例。如果您正苦于以下问题:C++ Pair::setMatches方法的具体用法?C++ Pair::setMatches怎么用?C++ Pair::setMatches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pair
的用法示例。
在下文中一共展示了Pair::setMatches方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
// trace back to find the alignment...
string out1("");
string out2("");
// find highest value
int highest = 0;
for (unsigned int iTest = 0; iTest < first->size( ) - 1; iTest++)
{
for (unsigned int jTest = 0; jTest < second->size( ) - 1; jTest++)
{
if (grid[iTest][jTest] >= highest)
{
highest = grid[iTest][jTest];
i = iTest;
j = jTest;
}
}
}
// i = first->size() - 1;
// j = second->size() - 1;
int score;
int score_diagonal;
int score_up;
int score_left;
int matches = 0;
while (i > 0 && j > 0)
{
score = grid[i][j];
score_diagonal = grid[i - 1][j - 1];
score_up = grid[i][j - 1];
score_left = grid[i - 1][j];
if (score == score_diagonal + sub->getScore(first->at((i - 1) * sizeof(char)), second->at((j - 1) * sizeof(char))))
{
pair->insertA(first->at((i - 1) * sizeof(char)));
pair->insertB(second->at((j - 1) * sizeof(char)));
i--;
j--;
matches++;/*
cout << "\nDiagonal" << endl;
cout << out1 << endl << out2 << endl;*/
}
else if (score == score_left + penalty)
{
pair->insertA(first->at((i - 1) * sizeof(char)));
pair->insertB('-');
i--;/*
cout << "\nLeft" << endl;
cout << out1 << endl << out2 << endl;*/
}
else //if (score == score_up + penalty)
{
pair->insertA('-');
pair->insertB(second->at((j - 1) * sizeof(char)));
j--;/*
cout << "\nUp" << endl;
cout << out1 << endl << out2 << endl;*/
}
if (grid[i][j] == 0)
{
break;
}
}
pair->setMatches(matches);
// while (i > 0)
// {
// pair->insertA(first->at((i-1) * sizeof(char)));
// pair->insertB('-');
// i--;
// cout << "\nLeft" << endl;
// cout << out1 << endl << out2 << endl;
// }
//
// while (j > 0)
// {
// pair->insertA('-');
// pair->insertB(second->at((j-1) * sizeof(char)));
// j--;
// cout << "\nUp" << endl;
// cout << out1 << endl << out2 << endl;
// }
/* print the grid
for (i = 0; i < first->size( ); i++)
{
for (j = 0; j < second->size( ); j++)
{
cout << "\t" << grid[i][j];
}
cout << endl;
}*/
pair->setScore(grid[first->size( ) - 1][second->size( ) - 1]);
// return aligned sequence
return pair;
}