本文整理汇总了C++中CardSet::rankstr方法的典型用法代码示例。如果您正苦于以下问题:C++ CardSet::rankstr方法的具体用法?C++ CardSet::rankstr怎么用?C++ CardSet::rankstr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CardSet
的用法示例。
在下文中一共展示了CardSet::rankstr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cards
std::set<CardSet>
expandRankSet(size_t numCards)
{
combinations cards(52,numCards);
do
{
CardSet hand;
for (size_t i=0; i<num_cards; i++)
{
hand.insert (Card(cards[i]));
}
collection.insert(hand.canonize());
rankHands[hand.rankstr()] = hand.rankColex();
}
while (cards.next());
}
示例2: main
int main (int argc, char ** argv)
{
try
{
// set up the program options, handle the help case, and extract the values
po::options_description desc("pscolex, a utility which prints all combinations\n"
"of poker hands, using canonical suits, or only ranks\n");
desc.add_options()
("help,?", "produce help message")
("num-cards,n", po::value<size_t>()->default_value(2), "number of cards in hands")
("ranks", "print the set of rank values")
;
po::variables_map vm;
po::store (po::command_line_parser(argc, argv)
.style(po::command_line_style::unix_style)
.options(desc)
.run(), vm);
po::notify (vm);
// check for help
if (vm.count("help") || argc == 1)
{
cout << desc << endl;
return 1;
}
// extract the options
size_t num_cards = vm["num-cards"].as<size_t>();
set<CardSet> canonicalHands;
map<string,size_t> rankHands;
combinations cards(52,num_cards);
do
{
CardSet hand;
for (size_t i=0; i<num_cards; i++)
{
hand.insert (Card(cards[i]));
}
canonicalHands.insert(hand.canonize());
rankHands[hand.rankstr()] = hand.rankColex();
}
while (cards.next());
if (vm.count("ranks") > 0)
{
for (auto it=rankHands.begin(); it != rankHands.end(); it++)
cout << boost::format("%s: %d\n") % it->first % it->second;
}
else
{
for (auto it=canonicalHands.begin(); it != canonicalHands.end(); it++)
cout << boost::format("%s: %d\n") % it->str() % it->colex();
}
}
catch(std::exception& e)
{
cerr << "-- caught exception--\n" << e.what() << "\n";
return 1;
}
catch(...)
{
cerr << "Exception of unknown type!\n";
return 1;
}
return 0;
}