本文整理汇总了C++中choice函数的典型用法代码示例。如果您正苦于以下问题:C++ choice函数的具体用法?C++ choice怎么用?C++ choice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了choice函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chgroup
static int chgroup(void) {
int p=notAllowed,c;
for(;;) {
switch(sym) {
case SYM_CHR: chkrch(val);
case SYM_ESC: c=val; getsym();
if(sym==SYM_CHR&&val=='-') {
if(regex[ri]=='[') {
p=choice(p,newChar(c));
goto END_OF_GROUP;
} else {
getsym();
switch(sym) {
case SYM_CHR: chkrch(val);
case SYM_ESC: p=choice(p,newRange(c,val)); getsym(); break;
default: error(RX_ER_BADCH); getsym(); break;
}
}
} else {
p=choice(p,newChar(c));
}
break;
case SYM_CLS: p=choice(p,cls(val)); getsym(); break;
case SYM_END: error(RX_ER_NORSQ); goto END_OF_GROUP;
default: assert(0);
}
if(sym==SYM_CHR&&(val==']'||val=='-')) goto END_OF_GROUP;
}
END_OF_GROUP:;
return p;
}
示例2: help
void help()
{
int helpchoice;
int secondchoice;
int done = FALSE;
do
{
helpchoice = choice(5,helpindex);
switch (helpchoice)
{
case 0 : done = TRUE;break;
case 1 : secondchoice = choice(4,layout);
switch (secondchoice)
{
case 0 : break;
case 1 : showhelp("Help : General Layout",layout_1);break;
case 2 : showhelp("Help : Screen 1",layout_2);break;
case 3 : showhelp("Help : Screen 2",layout_3);break;
case 4 : showhelp("Help : Screen 3",layout_4);break;
}
break;
case 2 : secondchoice = choice(3,entering);
switch (secondchoice)
{
case 0 : break;
case 1 : showhelp("Help : Movement",entering_1);break;
case 2 : showhelp("Help : Recalculation",entering_2);break;
case 3 : showhelp("Help : Editing",entering_3);break;
}
break;
case 3 : secondchoice = choosefunction();
switch (secondchoice)
{
case 0 : break;
case F01 : showhelp("Help : F1",keys_1);break;
case F02 : showhelp("Help : F2",keys_2);break;
case F03 : showhelp("Help : F3",keys_3);break;
case F04 : showhelp("Help : F4",keys_4);break;
case F05 : showhelp("Help : F5",keys_5);break;
case F06 : showhelp("Help : F6",keys_6);break;
case F07 : showhelp("Help : F7",keys_7);break;
case F08 : showhelp("Help : F8",keys_8);break;
case F09 : showhelp("Help : F9",keys_9);break;
case F10: showhelp("Help : F10",keys_10);break;
}
break;
case 4 : secondchoice = choice(2,graphing);
switch (secondchoice)
{
case 0 : break;
case 1 : showhelp("Help : Price Graphs",graphing_1);break;
case 2 : showhelp("Help : Time Graphs",graphing_2);break;
}
break;
case 5 : showhelp("Help : Notice to Users",notice); break;
}
} while (!done);
}
示例3: permutation
void permutation(WORDSIZE* state){
WORDSIZE a, b, c, d;
unsigned int index;
load_state(state, a, b, c, d);
for (index = 0; index < ROUNDS; index++){
a ^= index;
a ^= choice(f(b), f(c), f(d)); b ^= choice(f(c), f(d), f(a));
c ^= choice(f(d), f(a), f(b)); d ^= choice(f(a), f(b), f(c));}
store_state(state, a, b, c, d);}
示例4: choice
static int choice(int p1,int p2) {
if(P_IS(p1,P_NOT_ALLOWED)) return p2;
if(P_IS(p2,P_NOT_ALLOWED)) return p1;
if(P_IS(p2,P_CHOICE)) {
int p21,p22; Choice(p2,p21,p22);
p1=choice(p1,p21); return choice(p1,p22);
}
if(samechoice(p1,p2)) return p1;
if(nullable(p1) && (P_IS(p2,P_EMPTY))) return p1;
if(nullable(p2) && (P_IS(p1,P_EMPTY))) return p2;
return newChoice(p1,p2);
}
示例5: piece
static int piece(void) {
int p;
p=atom();
if(sym==SYM_CHR) {
switch(val) {
case '{': getsym(); p=quantifier(p); chk_get('}',RX_ER_NOLCU); break;
case '?': getsym(); p=choice(empty,p); break;
case '*': getsym(); p=choice(empty,one_or_more(p)); break;
case '+': getsym(); p=one_or_more(p); break;
default: break;
}
}
return p;
}
示例6: choice
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
/// Choice of a variant
void ChoiceCreate::on_next_choice_clicked()
{
if (ui->newContact->isChecked())
{
emit choice(QString("newContact"));
this->close();
}
if (ui->newGroup->isChecked())
{
emit choice(QString("newGroup"));
this->close();
}
}
示例7: solve
/* Attempt to solve 'board'; return 0 on success else -1 on error.
*
* The solution process attempts to fill-in deterministically as
* much of the board as possible. Once that is no longer possible,
* need to choose a square to fill in.
*/
static
int
solve( void )
{
int idx;
rb->yield();
while( 1 )
{
if( 0 == deterministic( ) )
{
/* Solved, make a new choice, or rewind a previous choice */
idx = choice( );
if( -1 == idx )
return 0;
else
if( ( idx < 0 || -1 == choose( idx, 1 ) ) && -1 == backtrack( ) )
return -1;
}
else /* rewind to a previous choice */
if( -1 == backtrack( ) )
return -1;
}
return -1;
}
示例8: ReaderCreate
/**
* @brief Create Reader
*/
Reader *
ReaderCreate(char *type)
{
const char *keys[] =
{
"BINARY",
"FIXED", /* alias for backward compatibility. */
"CSV",
"TUPLE",
"FUNCTION",
};
const ParserCreate values[] =
{
CreateBinaryParser,
CreateBinaryParser,
CreateCSVParser,
CreateTupleParser,
CreateFunctionParser,
};
Reader *self;
/* default of type is CSV */
if (type == NULL)
type = "CSV";
self = palloc0(sizeof(Reader));
self->max_parse_errors = -2;
self->limit = INT64_MAX;
self->checker.encoding = -1;
self->parser = values[choice("TYPE", type, keys, lengthof(keys))]();
return self;
}
示例9: choice
void wxExEx::MacroStartRecording(const wxString& macro)
{
if (!m_IsActive)
{
return;
}
wxString choice(macro);
if (choice.empty())
{
wxTextEntryDialog dlg(m_STC,
_("Input") + ":",
_("Enter Macro"),
m_Macros.GetMacro());
if (dlg.ShowModal() != wxID_OK)
{
return;
}
choice = dlg.GetValue();
}
m_Macros.StartRecording(choice);
}
示例10: choicePlaylists
int choicePlaylists(struct playLists arrPlaylist[20]){
system("cls");
int red = FOREGROUND_RED | FOREGROUND_INTENSITY;
int aqua = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
int i, numberPlaylists = 0, pointPl = 0, lll = 0;
format(2, 0, aqua);
printf("Your playlists");
for(i = 0; i < 20; i++){
if(strcmp(arrPlaylist[i].namelist, "\0") != 0){
numberPlaylists++;
if(i == 0)
format(0, 2*numberPlaylists, red);
else
format(0, 2*numberPlaylists, 7);
printf("%s", arrPlaylist[i].namelist);
}
}
while(lll == 0){
switch(getch()){
case 72: pointPl--;
break;
case 80: pointPl++;
break;
case 13: lll = 1;
break;
case 8:
return choice(0);
}
outPlaylists(numberPlaylists, arrPlaylist, pointPl);
}
menuPlaylist(arrPlaylist, pointPl);
}
示例11: get_global_variable
static void get_global_variable(persist_context &ctx, const vconfig &pcfg)
{
std::string global = pcfg["from_global"];
std::string local = pcfg["to_local"];
config::attribute_value pcfg_side = pcfg["side"];
const int side = pcfg_side.to_int(resources::controller->current_side());
persist_choice choice(ctx, global, side);
config cfg = mp_sync::get_user_choice("global_variable",choice,side).child("variables");
try
{
if (cfg) {
size_t arrsize = cfg.child_count(global);
if (arrsize == 0) {
resources::gamedata->set_variable(local,cfg[global]);
} else {
resources::gamedata->clear_variable(local);
for (size_t i = 0; i < arrsize; i++)
resources::gamedata->add_variable_cfg(local,cfg.child(global,i));
}
} else {
resources::gamedata->set_variable(local,"");
}
}
catch(const invalid_variablename_exception&)
{
ERR_PERSIST << "cannot store global variable into invalid variablename " << local << std::endl;
}
}
示例12: waitForKeypress
Action SDLKeyboardAgent::act() {
if (manual_control) {
return waitForKeypress();
}
else // Default to random agent
return choice(&available_actions);
}
示例13: quantifier
static int quantifier(int p0) {
int p=empty,n,n0;
n=n0=number();
while(n--) p=group(p,p0);
if(sym==SYM_CHR) {
if(val==',') {
getsym();
if(sym==SYM_CHR && val=='}') {
p=group(p,choice(empty,one_or_more(p0)));
} else {
n=number()-n0; if(n<0) {error(RX_ER_DNUOB); n=0;}
while(n--) p=group(p,choice(empty,p0));
}
}
} else error(RX_ER_NODGT);
return p;
}
示例14: expression
static int expression(void) {
int p;
p=branch();
while(sym==SYM_CHR&&val=='|') {
getsym();
p=choice(p,branch());
}
return p;
}
示例15: menu
int menu(int t){
void choice(char );
void colorstring(char s[],int t);
if(t==0){
textbackground(BLACK);
textcolor(LIGHTBLUE);
cprintf("���������������������������"); textcolor(LIGHTGRAY); cprintf("�["); textcolor(DARKGRAY); cprintf("MAIN"); textcolor(LIGHTGRAY); cprintf("]�"); textcolor(BLUE); cprintf("���������������������������"); printf("\n");
choice('E');
colorstring("Enter the dome.",1); printf("\n");
choice('C');
colorstring("View Unit.",1); printf("\n");
choice('S');
colorstring("Send Messages.",1); printf("\n");
choice('R');
colorstring("Read Messages.",1); printf("\n");
choice('B');
colorstring("Bulletins.",1); printf("\n");
choice('V');
colorstring("View Scores.",1); printf("\n");
choice('P');
colorstring("Change User Settings.",1); printf("\n");
choice('I');
colorstring("Instructions",1); printf("\n");
choice('Q');
colorstring("Quit the game!",1); printf("\n");
textcolor(LIGHTBLUE);
cprintf("�������������������������������"); textcolor(BLUE); cprintf("�������������������������������"); printf("\n");
}
if(t==96){
textbackground(BLACK);
textcolor(LIGHTBLUE);
cprintf("���������������������������"); textcolor(LIGHTGRAY); cprintf("�[");
}
if(t==97){
textcolor(LIGHTGRAY); cprintf("]�"); textcolor(BLUE); cprintf("���������������������������"); printf("\n");
}
if(t==98){
textcolor(LIGHTBLUE);
cprintf("�������������������������������"); textcolor(BLUE); cprintf("�������������������������������"); printf("\n");
}
return 0;
}