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); }
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; }
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);}
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); }
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; }
////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// /// 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(); } }
/* 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; }
/** * @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; }
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); }
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); }
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; } }
Action SDLKeyboardAgent::act() { if (manual_control) { return waitForKeypress(); } else // Default to random agent return choice(&available_actions); }
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; }
static int expression(void) { int p; p=branch(); while(sym==SYM_CHR&&val=='|') { getsym(); p=choice(p,branch()); } return p; }
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; }
PrologLexer::PrologLexer() { lexer.rules[Prolog::Spacing] = loop1(charOf(" \t\n\r")); lexer.rules[Prolog::LParen] = str("("); lexer.rules[Prolog::RParen] = str(")"); lexer.rules[Prolog::LBracket] = str("["); lexer.rules[Prolog::RBracket] = str("]"); lexer.rules[Prolog::OnlyIf] = str(":-"); lexer.rules[Prolog::Eq] = str("="); /* lexer.rules[Prolog::Lt] = str("<"); lexer.rules[Prolog::Gt] = str(">"); lexer.rules[Prolog::Le] = str("<="); lexer.rules[Prolog::Ge] = str(">="); lexer.rules[Prolog::Ne] = str("<>"); */ lexer.rules[Prolog::Dot] = str("."); lexer.rules[Prolog::Comma] = str(","); lexer.rules[Prolog::Semi] = str(";"); lexer.rules[Prolog::Bar] = str("|"); lexer.rules[Prolog::DomainsKw] = str("domains"); lexer.rules[Prolog::PredicatesKw] = str("predicates"); lexer.rules[Prolog::ClausesKw] = str("clauses"); lexer.rules[Prolog::AssertKw] = str("assert"); lexer.rules[Prolog::Str] = seq(str("\""), loop(anyBut(choice(str("\""), str("\n")))), str("\"")); shared_ptr<RegExp> digit = charIs([](QChar c) { return c.isDigit(); },"<digit>"); shared_ptr<RegExp> letter = charIs([](QChar c) { return c.isLetter(); }, "<letter>"); shared_ptr<RegExp> smallLetter = charIs([](QChar c) { return c.isLower(); }, "<lowercase>"); shared_ptr<RegExp> capitalLetter = charIs([](QChar c) { return c.isUpper(); }, "<uppercase>"); shared_ptr<RegExp> alpha = charIs([](QChar c) { return c.isLetterOrNumber(); },"<alphanumeric>"); shared_ptr<RegExp> symbol = charOf("+-/*<>="); shared_ptr<RegExp> digits = seq(loop1(digit), checkNo(letter)); shared_ptr<RegExp> smallLetterOrSymbol = choice(smallLetter, symbol); shared_ptr<RegExp> alphaOrUnderscore = choice(alpha, str("_")); shared_ptr<RegExp> alphaOrSymbol= choice(alpha, symbol); lexer.rules[Prolog::Num] = seq(digits, optional(seq(str("."), digits))); lexer.rules[Prolog::Symbol] = seq(smallLetterOrSymbol, loop(choice(digit, alphaOrSymbol))); lexer.rules[Prolog::Variable] = seq(choice(capitalLetter, str("_")), loop(choice(digit, alphaOrUnderscore))); }
int ymove(int a) { int o,b; while(1) { b=getkey(); if(b==77) { ++a; system("cls"); for(o=1;o<=12;o++) choice(a,o); gotoxy(0,0); } else if(b==75) { --a; system("cls"); for(o=1;o<=12;o++) choice(a,o); gotoxy(0,0); } else if(b==72) { a+=10; system("cls"); for(o=1;o<=12;o++) choice(a,o); gotoxy(0,0); } else if(b==80) { a=a-10; system("cls"); for(o=1;o<=12;o++) choice(a,o); gotoxy(0,0); } else if(b==SPACE) main(); else return 0; } }
int main() { char x,b; int a,o; system("cls"); printf("What type of Calendar you want to see...!!!\n\n"); printf("Press 'Y' for Yearly or Press 'M' for Monthly\n\n"); printf("For Instructions press 'I'\n\n"); printf("To exit press 'E'\n\n"); x=getch(); if(x=='M'||x=='m') { printf("\t\t::MONTHLY::"); printf("\n\nEnter a year : "); scanf("%d",&a); printf("\nEnter the number corresponding to a month: "); scanf("%d",&o); system("cls"); choice(a,o); gotoxy(0,0); mmove(a,o); } else if(x=='Y'||x=='y') { printf("\t\t::YEARLY::"); printf("\n\nEnter a year after 1800 : "); scanf("%d",&a); system("cls"); for(o=1;o<=12;o++) choice(a,o); gotoxy(0,0); ymove(a); } else if(x=='i'||x=='I') instr(); else if(x=='e'||x=='E') exit(1); else printf("Wrong Input...!!!"); printf("\n\n"); return 0; }
void SaveFileDialog::BrowseDirectories() { std::vector<std::pair<std::string, std::string> > dummy; FileDlg dlg ( m_current_dir_edit->Text(), "", false, false, dummy ); dlg.SelectDirectories ( true ); dlg.Run(); if ( !dlg.Result().empty() ) { // Normalize the path by converting it into a path and back fs::path choice ( *dlg.Result().begin() ); UpdateDirectory ( PathString ( fs::canonical ( choice ) ) ); } }
void statement() { enreg dreg; bool isjumpn; tokattr *pair; level++; trace("statement"); switch(current.token) { case rd: match(rd); genread(true); break; case wr: match(wr); genwrite(true); break; case alu: match(alu); genenc(false); match(assignop); exp(); break; case mar: match(mar); genmar(true); match(assignop); dreg = matchreg(); genbreg(dreg); break; case iconst: case reg: dreg = matchreg(); gencreg(dreg); if (dreg != r_mbr) genenc(true); match(assignop); exp(); break; case IF: match(IF); isjumpn = choice(); gencond(isjumpn ? 1 : 2 ); match(THEN); match(GOTO); pair = match(iconst); genaddr(pair->attr.num); break; case GOTO: match(GOTO); gencond(3); pair = match(iconst); genaddr(pair->attr.num); break; case halt: match(halt); genhalt(); break; default: break; } level--; }
static int drv(int p,int c) { int p1,p2,cf,cl,cn,ret,m; assert(!P_IS(p,P_ERROR)); m=new_memo(p,c); if(m!=-1) return M_RET(m); switch(P_TYP(p)) { case P_NOT_ALLOWED: case P_EMPTY: ret=notAllowed; break; case P_CHOICE: Choice(p,p1,p2); ret=choice(drv(p1,c),drv(p2,c)); break; case P_GROUP: Group(p,p1,p2); {int p11=group(drv(p1,c),p2); ret=nullable(p1)?choice(p11,drv(p2,c)):p11;} break; case P_ONE_OR_MORE: OneOrMore(p,p1); ret=group(drv(p1,c),choice(empty,p)); break; case P_EXCEPT: Except(p,p1,p2); ret=nullable(drv(p1,c))&&!nullable(drv(p2,c))?empty:notAllowed; break; case P_RANGE: Range(p,cf,cl); ret=cf<=c&&c<=cl?empty:notAllowed; break; case P_CLASS: Class(p,cn); ret=in_class(c,cn)?empty:notAllowed; break; case P_ANY: ret=empty; break; case P_CHAR: Char(p,cf); ret=c==cf?empty:notAllowed; break; default: ret=0; assert(0); } new_memo(p,c); M_SET(ret); accept_m(); return ret; }
void info::menu() { setfillstyle(1,15); bar3d(150,8,632,455,4,1); setbkcolor(15); for(int j=0;j<8;j++) box(j,j,630+j,470+j); setfillstyle(1,3); bar3d(0,0,150,650,10,1);//to display side strip setcolor(1); settextstyle(4,0,4); outtextxy(50,20,"O"); outtextxy(50,50,"R"); outtextxy(50,80,"I"); outtextxy(50,120,"E"); outtextxy(50,150,"N"); outtextxy(50,180,"T"); outtextxy(50,210,"A"); outtextxy(50,240,"L"); outtextxy(50,280,"B"); outtextxy(50,310,"A"); outtextxy(50,340,"N"); outtextxy(50,380,"K"); settextstyle(1,HORIZ_DIR,1); setcolor(0); setfillstyle(1,2); bar3d(300,100,500,150,4,1); setcolor(0); outtextxy(320,110," Access account"); //outtextxy(320,110," Access account"); setfillstyle(1,3); bar3d(300,180,500,230,4,1); bar3d(300,265,500,310,4,1); setcolor(6); outtextxy(303,190," Create new account"); outtextxy(303,190," Create new account"); outtextxy(380,275,"Exit"); //setcolor(6); outtextxy(380,275,"Exit"); // setfillstyle(1,3); task(choice()); }
int main() { int n, option; printf("Enter Number \t:\t"); scanf("%d", &n); printf("\nYou have entered\t:\t %d", n); printf("\nEnter your option to check the number:\n"); printf("\n1. PRIME NUMBER OR NOT"); printf("\n2. EVEN/ODD NUMBER"); printf("\n3. ABOVE ALL\n"); scanf("%d", &option); choice(option, n); return 0; }
int key_hook(int keycode, t_mlx *mlx) { if (keycode == 18) mlx->motion = 1; if (keycode == 19) mlx->motion = 0; if (keycode == 53) exit(0); if (keycode == 20) { mlx->maxiter -= 10; choice(mlx); } if (keycode == 21) { mlx->maxiter += 10; choice(mlx); } if (keycode == 69) zoom_set(ZOOM, ZOOM, mlx); if (keycode == 78) zoom_out(ZOOM, ZOOM, mlx); return (0); }
static void randseq(char *buf, size_t len, const uproc_alphabet *alpha, const uproc_matrix *probs) { size_t i; static bool rand_seeded = false; if (!rand_seeded) { srand(time(NULL)); rand_seeded = true; } for (i = 0; i < len; i++) { uproc_amino a = choice(probs, UPROC_ALPHABET_SIZE); buf[i] = uproc_alphabet_amino_to_char(alpha, a); } buf[i] = '\0'; }
bool vote( Ballot & b ) { bool isVoting = motovated(rng); if( isVoting ) { int result = choice(rng); b.flip(result); } return isVoting; }
/*获取根路径 * while(runing)<获取包的内容/根据类型作出不同操作> *recv_pk:获取类型/获取长度/根据长度来读取报文 * */ void server_do(node* n) { packet pk; bzero(&pk,sizeof(packet)); char filedir[128]={0}; strcpy(filedir,n->curdir); int running=1; while(running) { recv_pk(n->accept_fd,&pk); choice(n,&pk,&running,filedir); } printf("close:fd=%d\n",n->accept_fd); close(n->accept_fd); }
void start_find_select(void*) { RandomChoice choice(/*rand_,*/ size()); for(iter_rewind(); !iter_end(); iter_inc(), ++choice) { if(choice.choose()) { iter_get(find_s_, find_p_, find_o_); iter_free(); timer_->set_timer<App, &App::start_find>(1000, this, 0); return; } ++choice; } debug_->debug("!fnd %d %d", (int)choice.elements, (int)choice.current); }
bool wxExEx::MacroPlayback(const wxString& macro, int repeat) { if (!m_IsActive) { return false; } const wxArrayString macros(m_Macros.Get()); if (macros.size() == 0) { return false; } wxString choice(macro); if (choice.empty()) { wxSingleChoiceDialog dialog(m_STC, _("Input") + ":", _("Select Macro"), m_Macros.Get()); const int index = macros.Index(m_Macros.GetMacro()); if (index != wxNOT_FOUND) { dialog.SetSelection(index); } if (dialog.ShowModal() != wxID_OK) { return false; } choice = dialog.GetStringSelection(); } wxExSTC* stc = m_STC; const bool ok = m_Macros.Playback(this, choice, repeat); m_STC = stc; return ok; }
int main(int argc, char** argv) { Fl_Window window(5*75,400); window.box(FL_NO_BOX); Fl_Scroll scroll(0,0,5*75,300); Fl_Group g(0, 0, 5*75, 8*25); int n = 0; for (int y=0; y<16; y++) for (int x=0; x<5; x++) { char buf[20]; sprintf(buf,"%d",n++); if (y==8 && x==0) g.end(); Fl_Button* b = new Fl_Button(x*75,y*25+(y>=8?5*75:0),75,25,strdup(buf)); b->color(n); b->selection_color(n); b->label_color(FL_WHITE); b->selection_text_color(FL_WHITE); } g.end(); Drawing drawing(0,8*25,5*75,5*75,0); scroll.end(); window.resizable(scroll); Fl_Box box(0,300,5*75,window.h()-300); // gray area below the scroll box.box(FL_FLAT_BOX); Fl_Toggle_Button but1(150, 310, 200, 25, "box"); but1.set(); but1.callback(box_cb); Fl_Choice choice(150, 335, 200, 25, "type():"); choice.menu(choices); choice.value(3); Fl_Choice achoice(150, 360, 200, 25, "scrollbar_align():"); achoice.menu(align_choices); achoice.value(3); thescroll = &scroll; //scroll.box(FL_DOWN_BOX); //scroll.type(Fl_Scroll::VERTICAL); window.end(); window.show(argc,argv); return Fl::run(); }