可以显示一,二,三,四家的牌
主要是为了训练我的牌感(记牌的能力),对有志于赌博或者桥牌事业的同志可能还有点用
编译为bd.exe,使用方法输入"bd -h"看帮助
以下是源代码(处理命令行参数的代码参考了vim):
#include
#include
#include
#include
using namespace std;
#include
#include
#include
static char program_name[]="bd";
#define THE_VERSION "0.1"
namespace info{
enum { WEST=0,NORTH=1,EAST=2,SOUTH=3,};
};
static char* deno[]={"Spade","Heart","Diamond","Cotton",};
static char card_symbol[]="23456789TJQKA";
// p - pointer to argument
// idx - index in argument
// default value
static int
get_number_arg(char* p,int def)
{
if (isdigit(*p))
{
def = atoi(p);
}
return def;
}
static void
print_help()
{
cout<<"Usage: "< cout<<"Bridge Dealer"< cout<<"Example: "< cout< cout<<" -p number of players, value ranges from 1 to 4"< cout<<" \""< cout<<" -v,--version print version information and exit"< cout<<" -h,--help display this help and exit"< cout< exit(0);
}
static void
print_version()
{
cout<#define BS_UNKNOWN_OPTION 0
"Too many arguments",
#define BS_TOO_MANY_ARGS 1
"Argument missing after",
#define BS_ARG_MISSING 2
"Garbage after option",
#define BS_GARBAGE 3
"Too many extra commands",
#define BS_EXTRA_CMD 4
"Invalid argument for",
#define BS_INVALID_ARG 5
};
//error message routines---------------end
int
main(int argc, char** argv)
{