static Int getNearSidesArea(Area a, Area b, Int distance) { int d=valInt(distance); int a_top, a_center, a_bottom, a_left, a_middle, a_right; int b_top, b_center, b_bottom, b_left, b_middle, b_right; register unsigned long mask; InitAreaA; InitAreaB; NormaliseArea(ax, ay, aw, ah); NormaliseArea(bx, by, bw, bh); a_top = ay; a_bottom = ay+ah-1; a_center = (a_top+a_bottom+1)/2; a_left = ax; a_right = ax+aw-1; a_middle = (a_left+a_right+1)/2; b_top = by; b_bottom = by+bh-1; b_center = (b_top+b_bottom+1)/2; b_left = bx; b_right = bx+bw-1; b_middle = (b_left+b_right+1)/2; mask = 0; NEAR(a_top, b_top, d, mask, 01); NEAR(a_top, b_center, d, mask, 02); NEAR(a_top, b_bottom, d, mask, 04); NEAR(a_center, b_top, d, mask, 010); NEAR(a_center, b_center, d, mask, 020); NEAR(a_center, b_bottom, d, mask, 040); NEAR(a_bottom, b_top, d, mask, 0100); NEAR(a_bottom, b_center, d, mask, 0200); NEAR(a_bottom, b_bottom, d, mask, 0400); NEAR(a_left, b_left, d, mask, 01000); NEAR(a_left, b_middle, d, mask, 02000); NEAR(a_left, b_right, d, mask, 04000); NEAR(a_middle, b_left, d, mask, 010000); NEAR(a_middle, b_middle, d, mask, 020000); NEAR(a_middle, b_right, d, mask, 040000); NEAR(a_right, b_left, d, mask, 0100000); NEAR(a_right, b_middle, d, mask, 0200000); NEAR(a_right, b_right, d, mask, 0400000); answer(toInt(mask)); }
int command(isdn_ctrl *cmd) { int card; card = get_card_from_id(cmd->driver); if(!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } pr_debug("%s: Received %s command from Link Layer\n", sc_adapter[card]->devicename, commands[cmd->command]); /* * Dispatch the command */ switch(cmd->command) { case ISDN_CMD_IOCTL: { unsigned long cmdptr; scs_ioctl ioc; memcpy(&cmdptr, cmd->parm.num, sizeof(unsigned long)); if (copy_from_user(&ioc, (scs_ioctl __user *)cmdptr, sizeof(scs_ioctl))) { pr_debug("%s: Failed to verify user space 0x%x\n", sc_adapter[card]->devicename, cmdptr); return -EFAULT; } return sc_ioctl(card, &ioc); } case ISDN_CMD_DIAL: return dial(card, cmd->arg, cmd->parm.setup); case ISDN_CMD_HANGUP: return hangup(card, cmd->arg); case ISDN_CMD_ACCEPTD: return answer(card, cmd->arg); case ISDN_CMD_ACCEPTB: return acceptb(card, cmd->arg); case ISDN_CMD_CLREAZ: return clreaz(card, cmd->arg); case ISDN_CMD_SETEAZ: return seteaz(card, cmd->arg, cmd->parm.num); case ISDN_CMD_SETL2: return setl2(card, cmd->arg); case ISDN_CMD_SETL3: return setl3(card, cmd->arg); default: return -EINVAL; } return 0; }
std::vector<std::vector<Real> > RichardsSeff2gasRSC::d2seff(std::vector<VariableValue *> p, unsigned int qp) const { Real pc = (*p[1])[qp] - (*p[0])[qp]; std::vector<std::vector<Real> > answer(2); answer[0].resize(2); answer[1].resize(2); answer[1][1] = -RichardsSeffRSC::d2seff(pc, _shift, _scale); answer[0][1] = -answer[1][1]; answer[1][0] = -answer[1][1]; answer[0][0] = answer[1][1]; return answer; }
// check the return code to see if it's a redirection request bool HTTPHeader::isRedirection() { // The 1st line of the header for a redirection is thus: // HTTP/1.(0|1) 3xx if (header.size() < 1) { return false; } // sometimes get called b 4 read String answer(header.front().after(" ").before(" ")); if (answer[0] == '3' && answer.length() == 3) { return true; } return false; }
int main(void){ int a; printf("欢迎来到我的程序。\n本程序用于生成一个汉诺塔问题的解。\n至于什么是汉诺塔问题,请自行百度。\n现在请输入圆盘的数量。\n(注:初始圆盘是A,目标是C,媒介是B)\n"); scanf("%d",&a); printf("\n"); answer(a,'a','b','c'); printf("\nthanks for using my program.\n\n\n\n ——ice1000 千里冰封\n\n\n"); system("pause"); return 0; }
string getCurrentUrl() { RegEntry r(HKEY_CLASSES_ROOT, "HTTP\\Shell\\open\\ddeexec\\application"); string topic = r.value(""); if (topic.empty()) return ""; DDEbase b; DDEconversation conv(topic.c_str(), "WWW_GetWindowInfo"); DDEdataHandle answer(conv.Execute("-1")); const char *url = answer; return url; }
std::vector<std::vector<Real> > RichardsSeff2waterVG::d2seff(std::vector<VariableValue *> p, unsigned int qp) const { Real negpc = (*p[0])[qp] - (*p[1])[qp]; std::vector<std::vector<Real> > answer(2); answer[0].resize(2); answer[1].resize(2); answer[0][0] = RichardsSeffVG::d2seff(negpc, _al, _m); answer[0][1] = -answer[0][0]; answer[1][0] = -answer[0][0]; answer[1][1] = answer[0][0]; return answer; }
// see portalLib1.h for the cube struct: It has int x and int y void speed_assessment(cube c, int N, double s[]){ int T = 0; int L = 0; for(int i=0;i<N;i++) { double t = c.x / s[i]; if(t*t/2>=c.y && t*t/2<=c.y+1) L++; else { t = sqrt(c.y * 2); if(t*s[i]>=c.x && t*s[i]<=c.x+1) T++; } } answer(T,L); }
static Method getMethodMethodList(Any list, Name sel) { if ( instanceOfObject(list, ClassMethod) ) { Method m = list; if ( m->name == sel ) answer(m); fail; } else if ( instanceOfObject(list, ClassChain) ) { Chain ch = list; Cell cell; Method m; for_cell(cell, ch) { if ( (m = getMethodMethodList(cell->value, sel)) ) answer(m); } fail; } else { errorPce(list, NAME_unexpectedType, CtoType("method|chain"));
static int check_fds_read(t_connect *connect) { unsigned char buffer[1500]; if (FD_ISSET(connect->sock, &(connect->mask_read))) { ft_bzero(buffer, 1500); recv(connect->sock, buffer, 1500, 0); answer(connect, buffer); return (2); } return (0); }
void Essay::fillAnswer() { EssayQuestion *qq = question(); String answer(mEditor->document()->toPlainText().toStdString()); if (answer == qq->filledAnswer()) { return; } qq->fill(answer); emit answerModified(qq); }
void automaticanswertest::createContent() { qDebug () << "automaticanswertest::createContent<<"; QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical); answering = new HbPushButton(tr("start autom. answer"), this); connect(answering, SIGNAL(clicked()), this, SLOT(answer())); mainLayout->addItem(answering); stopanswering = new HbPushButton(tr("stop autom. answer"), this); connect(stopanswering, SIGNAL(clicked()), this, SLOT(stopanswer())); mainLayout->addItem(stopanswering); stopanswering->setEnabled(false); setLayout(mainLayout); }
std::vector<int> containing_tree(const std::vector<Rectangle<T>> &rects){ typedef std::pair<int, int> pii; typedef std::tuple<int, int, int, int> tiiii; const int n = rects.size(); CoordinateCompressor<T> xcomp, ycomp; for(int i = 0; i < n; ++i){ xcomp.push(rects[i].x1); ycomp.push(rects[i].y1); xcomp.push(rects[i].x2); ycomp.push(rects[i].y2); } xcomp.build(); ycomp.build(); std::vector<std::pair<Rectangle<int>, int>> rs(n); for(int i = 0; i < n; ++i){ const auto &r = rects[i]; rs[i] = std::make_pair(Rectangle<int>( xcomp.compress(r.x1), ycomp.compress(r.y1), xcomp.compress(r.x2), ycomp.compress(r.y2)), i); } std::sort(rs.begin(), rs.end()); const int m = xcomp.size(); std::vector<std::set<pii>> raw_bit(m + 1); std::priority_queue<tiiii, std::vector<tiiii>, std::greater<tiiii>> pq; std::vector<int> parents(n, -1); for(int i = 0; i < n; ++i){ const auto &r = rs[i].first; while(!pq.empty() && std::get<0>(pq.top()) <= r.y1){ for(int j = std::get<1>(pq.top()) + 1; j <= m; j += j & -j){ raw_bit[j].erase(std::make_pair( std::get<2>(pq.top()), std::get<3>(pq.top()))); } pq.pop(); } pii answer(xcomp.size(), n); for(int j = r.x1; j > 0; j -= j & -j){ const auto it = raw_bit[j].lower_bound(std::make_pair(r.x2, -1)); if(it != raw_bit[j].end()){ answer = std::min(answer, *it); } } const int k = rs[i].second; for(int j = r.x1 + 1; j <= m; j += j & -j){ raw_bit[j].insert(std::make_pair(r.x2, k)); } parents[k] = (answer.second >= n ? -1 : answer.second); pq.push(std::make_tuple(r.y2, r.x1, r.x2, k)); } return parents; }
std::vector<int> getRow(const int &rowIndex) { std::vector<int> answer(rowIndex + 1, 1); int mul = rowIndex; int div = 1; for (int i = 1; i <= answer.size() / 2; i++) { int value = static_cast<unsigned long long int> (answer[i - 1]) * mul / div; answer[i] = value; answer[answer.size() - i - 1] = value; mul--; div++; } return answer; }
void MakeSlowCapturingTest(const char* regexp, const char* text, size_t position, bool ans, const ystring& captured = ystring(""), const Pire::Encoding& encoding = Pire::Encodings::Utf8()) { Pire::SlowCapturingScanner sc = SlowCompile(regexp, position, encoding); SlowCapturingScanner::State st = RunRegexp(sc, text); SlowCapturingScanner::SingleState fin; bool ifCaptured = sc.GetCapture(st, fin); if (ans) { UNIT_ASSERT(ifCaptured); ystring answer(text, fin.GetBegin(), fin.GetEnd() - fin.GetBegin()); UNIT_ASSERT_EQUAL(answer, captured); } else { UNIT_ASSERT(!ifCaptured); } }
BitMap MethodLiveness::get_liveness_at(int entry_bci) { int bci = entry_bci; bool is_entry = false; if (entry_bci == InvocationEntryBci) { is_entry = true; bci = 0; } BitMap answer(NULL,0); if (_block_list->length() > 0) { if (TimeLivenessAnalysis) _time_total.start(); if (TimeLivenessAnalysis) _time_query.start(); assert( 0 <= bci && bci < method()->code_size(), "bci out of range" ); BasicBlock *block = _block_map->at(bci); assert( block != NULL, "invalid bytecode index; must be instruction index" ); answer = block->get_liveness_at(method(), bci); if (is_entry && method()->is_synchronized() && !method()->is_static()) { // Synchronized methods use the receiver once on entry. answer.at_put(0, true); } #ifndef PRODUCT if (TraceLivenessQuery) { tty->print("Liveness query of "); method()->print_short_name(); tty->print(" @ %d : result is ", bci); answer.print_on(tty); } if (TimeLivenessAnalysis) _time_query.stop(); if (TimeLivenessAnalysis) _time_total.stop(); #endif } #ifndef PRODUCT if (TimeLivenessAnalysis) { // Collect statistics. _total_locals_queried += _bit_map_size_bits; BitCounter counter; answer.iterate(&counter); _total_live_locals_queried += counter.count(); } #endif return answer; }
// ---------------------------------------------------------------------------- // CAknExQueryContainer::ShowDataQueryL() // Display of Data Query. // ---------------------------------------------------------------------------- // void CAknExQueryContainer::ShowDataQueryL( const TInt aQueryResourceId, const TInt aTextResourceId, const TInt aPromptResourceId, const TInt aMaxLength, const TBool aDisplayFlag ) { iDisplayDialog = ETrue; SetTextToLabelL( R_AKNEXQUERY_OPERATE_MESSAGE ); TBuf<KAknExQueryTextBufLength> textData; if ( aTextResourceId ) { iCoeEnv->ReadResource( textData, aTextResourceId ); } CAknTextQueryDialog* dlg; if ( !aPromptResourceId ) { dlg = new ( ELeave )CAknTextQueryDialog( textData, CAknQueryDialog::ENoTone ); } else { TBuf<KAknExQueryTextBufLength> prompt; iCoeEnv->ReadResource( prompt, aTextResourceId ); dlg = CAknTextQueryDialog::NewL( textData, CAknQueryDialog::ENoTone ); CleanupStack::PushL( dlg ); dlg->SetPromptL( prompt ); CleanupStack::Pop(); // dlg } if ( aMaxLength ) { dlg->SetMaxLength( aMaxLength ); } TBool answer( dlg->ExecuteLD( aQueryResourceId ) ); if ( aDisplayFlag && answer ) { iLabelResultMessage->SetTextL( textData ); } iDisplayDialog = EFalse; DrawNow(); }
/* assumption: input limited; accept blocking on output */ static int master(void) { for (;; ) { lsw_fd_set readfds; int maxfd = PLUTO_QFD; /* approximate lower bound */ int ndes = 0; struct worker_info *w; LSW_FD_ZERO(&readfds); if (!eof_from_pluto) { LSW_FD_SET(PLUTO_QFD, &readfds); ndes++; } for (w = wi; w != wi_roof; w++) { if (w->busy) { LSW_FD_SET(w->afd, &readfds); ndes++; if (maxfd < w->afd) maxfd = w->afd; } } if (ndes == 0) return HES_OK; /* done! */ do ndes = lsw_select(maxfd + 1, &readfds, NULL, NULL, NULL); while (ndes == -1 && errno == EINTR); if (ndes == -1) { syslog(LOG_ERR, "select(2) error: %s", strerror(errno)); exit(HES_IO_ERROR_SELECT); } else if (ndes > 0) { if (LSW_FD_ISSET(PLUTO_QFD, &readfds)) { query(); ndes--; } for (w = wi; ndes > 0 && w != wi_roof; w++) { if (w->busy && LSW_FD_ISSET(w->afd, &readfds)) { answer(w); ndes--; } } } } }
static Elevation getConvertElevation(Any receiver, Any val) { Int i; Elevation e; if ( (e= getLookupElevation(receiver, val, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)) ) return e; if ( (i = toInteger(val)) ) answer(answerObject(ClassElevation, i, i, EAV)); fail; }
/** * Once you have collected all the integers, build the bitmaps. */ static std::vector<vector > create_all_bitmaps(size_t *howmany, uint32_t **numbers, size_t count) { if (numbers == NULL) return std::vector<vector >(); std::vector<vector > answer(count); for (size_t i = 0; i < count; i++) { vector & bm = answer[i]; uint32_t * mynumbers = numbers[i]; for(size_t j = 0; j < howmany[i] ; ++j) { bm.push_back(mynumbers[j]); } bm.shrink_to_fit(); } return answer; }
//处理ask for clients 请求 void talk_to_client::do_anw_clients() { if (!_started)return; std::string answer(requests.request_ask); for (std::map<std::string, client_ptr>::iterator it = clients.begin(); it != clients.end(); ++it) { answer += it->first + " "; } if (clients.empty()){ do_write(requests.request_ask + "谭伟丰 陈明浩 陈伦宝 \n"); } answer += "\n"; do_write(answer); }
Elevation getModifyElevation(Elevation e, Name att, Any val) { if ( notNil(e->name) ) { Int height = e->height; Any colour = e->colour; Any relief = e->relief; Any shadow = e->shadow; Any bg = e->background; Name kind = e->kind; if ( att == NAME_height ) height = val; else if ( att == NAME_colour ) colour = val; else if ( att == NAME_relief ) relief = val; else if ( att == NAME_shadow ) shadow = val; else if ( att == NAME_kind ) kind = val; else if ( att == NAME_background ) bg = val; answer(answerObject(ClassElevation, NIL, height, colour, relief, shadow, kind, bg, EAV)); } else { attributeElevation(e, att, val); answer(e); } }
int get_url(int sockcnfd,char *cmd,char *url) { char *cpt; char buf[MAXSIZE]; if(strncmp(cmd,"GET",3)!=0){ answer(sockcnfd,501,"not implemented", "text/plain","request error"); printf("request error \n"); return -1; } cpt=strchr(cmd,'/'); sscanf(cpt,"%s",buf); strcat(url,buf); return 0; }
ics::HashMap<T,int> HashEquivalence<T>::heights () const { ics::HashMap<T,int> answer(hash); for (auto np : parent) { T e = np.first; int depth = 0; while (parent[e] != e) { e = parent[e]; depth++; } int so_far = answer[e]; if (so_far < depth) answer[e] = depth; } return answer; }
static Any getCatchAllHostv(Host h, Name selector, int argc, Any *argv) { Any rval; if ( h->callBack == OFF ) { errorPce(h, NAME_noCallBack); fail; } if ( !(rval = getCallHostv(h, selector, argc, argv)) && PCE->last_error == NAME_noBehaviour ) assign(PCE, last_error, NIL); answer(rval); }
std::pair<Vector2D, double> FindBestPointToShoot::bestTarget(){ boost::uniform_int<int> uni_distX(-distance/2, distance/2); boost::variate_generator<boost::mt19937, boost::uniform_int<int> >genX(rngX, uni_distX); boost::uniform_int<int> uni_distY( -distance/2, distance/2); boost::variate_generator<boost::mt19937, boost::uniform_int<int> >genY(rngY, uni_distY); std::vector<Pose> obs = gamestate->getEnemyRobotsPos( this->rid ); std::vector<Pose>::iterator ii; double bestScore = std::numeric_limits<double>::min(); double angleToShoot; Vector2D bestAnswer = point;; for(int i=0;i<1000;i++){ bool collision = false; double x=genX(); double y=genY(); double tx= x/1000.0; double ty = y/1000.0; Vector2D answer(point.x+tx,point.y+ty); std::vector<Pose>::iterator ii = obs.begin(); for(ii = obs.begin() ;ii != obs.end();ii++){ if( pow(answer.x -ii->get<0>(),2) + pow(answer.y - ii->get<1>(),2) <= pow(Config::getInstance().getRRTRobotRadius(),2) ){ collision = true; } } if(collision) continue; Vector2D v(0,0); Pose pos(answer,0); gamestate->updateRobotData(robotName,pos,v,0); double tmpAngleToShoot; double score = 0; std::pair<double, double> ang =evaluation.aimAtGoal( gamestate,robotName, tmpAngleToShoot,score); if(score > bestScore){ bestScore = score; bestAnswer = answer; angleToShoot = tmpAngleToShoot; } } return std::pair<Vector2D, double>(bestAnswer,angleToShoot); }
int main() { compute_inverse(); int n = 0 , k = 0 , t , i=0, j=1; scanf("%d",&t); while(t--) { scanf("%d %d",&n,&k); for(i=0;i<n;i++) scanf("%lld",&ar[i]); std::sort( ar , ar + n ); printf("Case #%d: %lld\n",j++,answer(n,k)); } }
void TupWebHunter::closeRequest(QNetworkReply *reply) { QByteArray array = reply->readAll(); QString answer(array); if (k->type == Currency) { answer = answer.mid(answer.indexOf("\n"), answer.length()).trimmed(); QDomDocument doc; if (doc.setContent(answer)) { QDomElement root = doc.documentElement(); if (!root.text().isNull()) emit dataReady(k->currency + ":" + root.text()); } } }
static Graphical getLabelItem(Graphical item) { Chain ch; if ( (ch = getAllHypersObject(item, OFF)) ) { Cell cell; for_cell(cell, ch) { Hyper h = cell->value; if ( h->to == item && h->backward_name == NAME_label && instanceOfObject(h->from, ClassGraphical) ) answer(h->from); /* I'm an item */ if ( h->from == item && h->forward_name == NAME_item ) fail; /* I'm a label */ }
int init_telnet(void) { tellen = 0; answer (DO, TN_SUPPRESS_GA); answer (WILL, TN_SUPPRESS_GA); answer (DO, TN_TRANSMIT_BINARY); answer (WILL, TN_TRANSMIT_BINARY); answer (DO, TN_ECHO); answer (WILL, TN_ECHO); return 1; }