Intersection detecteTypeIntersection() { Intersection intersectionType = inter_none; if ( isCenter() && ( isLeft() || isRight() )) { // Permettra un meilleur redressement par la suit enregistrerDernierCapteurActif( dernierCapteurActif, dernierCapteurCoteActif ); // Teste si une ligne est détectée à gauche // cas possibles: cross, tBase, tRight, lLeft. if( isLeft() ) { trouverTypeIntersectionPourUnCote( intersectionType, capteur_gauche, capteur_droit ); } // Teste si une ligne est détectée à droite // cas possibles: cross, tBase, tLeft, lRight. else if( isRight() ) { trouverTypeIntersectionPourUnCote( intersectionType, capteur_droit, capteur_gauche ); } } return intersectionType; }
HTEXTURE getButtonTex(int w, int h, DWORD color, float gardientDelta) { HTEXTURE tex = hge->Texture_Create(w*2, h); DWORD *ptr = hge->Texture_Lock(tex, false, 0, 0, w*2, h); HSVColor tempCol(color); float uV = isRight(tempCol.getValue()-gardientDelta); float dV = isRight(tempCol.getValue()+gardientDelta); for (int x = 0; x<w*2; x++) for (int y = 0; y<h; y++) { if (x == w-1 || x == w || ((x<w*2-1 && x>w-1) && y == 0) || ((x>0 && x<w-1) && y == h-1)) { ptr[y*w*2 + x] = tempCol.setValue(0.15); tempCol = color; } else if (x == 0 || x == w*2-1 || (x<w-1 && y == 0) || (x>w && y == h-1)) { ptr[y*w*2 + x] = tempCol.setValue(1); tempCol = color; } else if (x>w) { ptr[y*w*2 + x] = tempCol.setValue(getValueFromY(y,0,h,uV,dV)); tempCol = color; } else { ptr[y*w*2 + x] = tempCol.setValue(getValueFromY(y,0,h,dV,uV)); tempCol = color; } } hge->Texture_Unlock(tex); return tex; }
void AdvHuffman::switchNode(int A, int B) /* Menukar 2 buah node pada pohon yang sama */ { int temp = A; int parentA= TabNode[A].getParent(); int parentB= TabNode[B].getParent(); if (isLeft(A) && (isRight(B))){ TabNode[parentA].setLeft(B); TabNode[parentB].setRight(temp); TabNode[temp].setParent(parentB); TabNode[B].setParent(parentA); } else if (isLeft(A) && (isLeft(B))){ TabNode[parentA].setLeft(B); TabNode[parentB].setLeft(temp); TabNode[temp].setParent(parentB); TabNode[B].setParent(parentA); } else if (isRight(A) && (isLeft(B))){ TabNode[parentA].setRight(B); TabNode[parentB].setLeft(temp); TabNode[temp].setParent(parentB); TabNode[B].setParent(parentA); } else { TabNode[parentA].setRight(B); TabNode[parentB].setRight(temp); TabNode[temp].setParent(parentB); TabNode[B].setParent(parentA); } }
Tile calculateTile( const Tile origin, const Tile direction ) { return (isLeft(origin) && isLeft(direction) || isRight(origin) && isRight(direction) || isTopRow(origin) && isTopRow(direction) || isBottomRow(origin) && isBottomRow(direction)) ? eTile_Count : static_cast<Tile>(origin + (direction - eTile_Origin)); }
/* handle id, literals, and (...) */ static Expression *e1(void) { if (isLeft()) { /* ( <expression> ) */ consume(); Expression *e = expression(); if (!isRight()) { error(); } consume(); return e; } else if (isInt()) { /* 123 */ int v = getInt(); consume(); Expression *e = NEW(Expression); e->kind = eVAL; e->val = v; return e; } else if (isId()) { /* xyz */ char *id = getId(); consume(); if (isLeft()) { /* xyz ( <actuals> ) */ consume(); Expression *e = NEW(Expression); e->kind = eCALL; e->callName = id; e->callActuals = actuals(); if (!isRight()) error(); consume(); return e; } else { Expression *e = NEW(Expression); e->kind = eVAR; e->varName = id; return e; } } else { error(); return 0; } }
// Specify the residual. This is where the ODE system and boundary // conditions are specified. The solver will attempt to find a solution // x so that this function returns 0 for all n and j. virtual doublereal residual(doublereal* x, size_t n, size_t j) { // if n = 0, return the residual for the first ODE if (n == 0) { if (isLeft(j)) { // here we specify zeta(0) = 0 return zeta(x,j); } else // this implements d(zeta)/dz = u { return (zeta(x,j) - zeta(x,j-1))/(z(j)-z(j-1)) - u(x,j); } } // if n = 1, then return the residual for the second ODE else { if (isLeft(j)) { // here we specify u(0) = 0 return u(x,j); } else if (isRight(j)) { // and here we specify u(L) = 1 return u(x,j) - 1.0; } else // this implements the 2nd ODE { return cdif2(x,1,j) + 0.5*zeta(x,j)*centralFirstDeriv(x,1,j); } } }
/* fun <id> ( <formals> ) <body> */ static Fun *fun() { if (!isFun()) return 0; consume(); Fun *p = NEW(Fun); if (!isId()) error(); p->name = getId(); consume(); if (!isLeft()) error(); consume(); p->formals = formals(); if (!isRight()) error(); consume(); p->body = statement(); return p; }
int scanner(const char *code) { int i = 0; int ret = 0; LinkStack *stack = LinkStack_Create(); while ( code[i] != '\0') { if ( isLeft(code[i]) ) LinkStack_Push(stack, (void*)(code+i)); if ( isRight(code[i]) ) { char* c = (char*)LinkStack_Pop(stack); if ( (c==NULL) || !match(*c, code[i]) ) { printf("%c does not match!\n", code[i]); ret = 0; break; } } i++; } if ( LinkStack_Size(stack)==0 && code[i]=='\0') { printf("success!\n"); ret = 1; } else { printf("failed!\n"); ret = 0; } LinkStack_Destroy(stack); return ret; }
void Creep::draw(sf::RenderWindow &window) { if (tileSet_) { sf::Sprite creepSprite = tileSet_->getSpriteById(1); sf::Vector2f position = getPosition(); int drawnSize = TileSet::getDrawnSize(); creepSprite.setOrigin(drawnSize/2.f,drawnSize/2.f); position.x += drawnSize/2.f; position.y += drawnSize/2.f; creepSprite.setPosition(position); int goingTo = paths_.getNextByID(comingFrom_); if (isAbove(comingFrom_,goingTo)) { creepSprite.setRotation(180); }else if (isBelow(comingFrom_,goingTo)) { creepSprite.setRotation(0); }else if (isLeft(comingFrom_,goingTo)) { creepSprite.setRotation(90); }else if (isRight(comingFrom_,goingTo)) { creepSprite.setRotation(270); } window.draw(creepSprite); } return; }
void tranform(const char * exp) { int i = 0; LinkStack * stack = LinkStack_Create(); while ( exp[i] != '\0' ) { if ( isNumber(exp[i]) ) print(exp[i]); else if ( isOperator(exp[i]) ) { while (priority(exp[i]) <= priority((char)(int)LinkStack_Top(stack)) ) { print((char)(int)LinkStack_Pop(stack)); } LinkStack_Push(stack, (void*)(int)exp[i]); } else if ( isLeft(exp[i]) ) { LinkStack_Push(stack, (void*)(int)exp[i]); } else if ( isRight(exp[i]) ) { char c = 0; while ((c=(char)(int)LinkStack_Pop(stack)) != '(') print(c); } else { printf("invalid expression!\n"); break; } i++; } while ( LinkStack_Size(stack)>0 && exp[i]=='\0') print((char)(int)LinkStack_Pop(stack)); LinkStack_Destroy(stack); }
Status scanner(char* c){ LinkStack* stack = NULL; InitStack(&stack); Status ret = FALSE; int i = 0; while(c[i] != '\0'){ elemType e; if( isLeft(c[i]) ){ Push(stack,(elemType)c[i]); } if(isRight(c[i])){ char codeOut; Pop(stack,&e); codeOut = (char)e; if(!isMatch(codeOut,c[i])){ printf("not matching %c %c\n",codeOut,c[i]); ret = FALSE; goto EXIT; } } i++; } if(StackEmpty(stack)){ ret = TRUE; }else{ ret = FALSE; } EXIT: ClearStack(&stack); return ret; }
void printType(double angleA, double angleB, double angleC) { if(isRight(angleA, angleB, angleC)) printf("right\n"); else if(angleA > 90 || angleB > 90 || angleC > 90) printf("obtuse\n"); else printf("acute\n"); }
bool balayer(uint8_t vitesse , uint16_t tempsBalayage, Direction dir) { bool ligneDetectee = (isLeft() || isCenter() || isRight()) ; while (!ligneDetectee && tempsBalayage > 0) { if (dir == direction_left) pivoterAntiHoraire(vitesse); else pivoterHoraire(vitesse); _delay_ms(1); ligneDetectee = (isLeft() || isCenter() || isRight()) ; tempsBalayage -- ; } arreterRobot(); enregistrerDernierCapteurActif(dernierCapteurActif, dernierCapteurCoteActif); return ligneDetectee ; }
sf::Vector2f Creep::getFuturePosition(double timeDelta) { int drawnSize = TileSet::getDrawnSize(); sf::Vector2f pos = getPosition(); float distanceDelta(timeDelta*speed_*drawnSize); while (distanceDelta > 0) { int goingTo = paths_.getNextByID(comingFrom_); if (isLeft(comingFrom_,goingTo)) { //coming from left of goingTo float distanceIntoTile = pos.x - (comingFrom_%paths_.getNumTilesX())*drawnSize; if (distanceDelta >= drawnSize - distanceIntoTile) { distanceDelta -= (drawnSize-distanceIntoTile); pos.x = (goingTo%paths_.getNumTilesX())*drawnSize; comingFrom_ = goingTo; }else { pos.x += distanceDelta; distanceDelta = 0; } }else if (isRight(comingFrom_,goingTo)) { //coming from right of goingTo float distanceIntoTile = (comingFrom_%paths_.getNumTilesX())*drawnSize - pos.x; if (distanceDelta >= drawnSize - distanceIntoTile) { distanceDelta -= (drawnSize - distanceIntoTile); pos.x = (goingTo%paths_.getNumTilesX())*drawnSize; comingFrom_ = goingTo; }else { pos.x -= distanceDelta; distanceDelta = 0; } }else if (isAbove(comingFrom_,goingTo)) {//coming from above goingTo float distanceIntoTile = pos.y - comingFrom_/paths_.getNumTilesX() * drawnSize; if (distanceDelta >= drawnSize - distanceIntoTile) { distanceDelta -= (drawnSize - distanceIntoTile); pos.y = (goingTo/paths_.getNumTilesX()) * drawnSize; comingFrom_ = goingTo; }else { pos.y += distanceDelta; distanceDelta = 0; } }else if (isBelow(comingFrom_,goingTo)) {//coming from below goingTo float distanceIntoTile = comingFrom_/paths_.getNumTilesX() * drawnSize - pos.y; if (distanceDelta >= drawnSize - distanceIntoTile) { distanceDelta -= (drawnSize - distanceIntoTile); pos.y = (goingTo/paths_.getNumTilesX()) * drawnSize; comingFrom_ = goingTo; }else { pos.y -= distanceDelta; distanceDelta = 0; } }else if (comingFrom_ == goingTo) { distanceDelta = 0; leaked_ = true; } } return pos; }
void SplitterByCenter<TBv>::split(TVertices& left, TVertices& right) const { for (unsigned i = 0; i < mVertices.size(); ++i) { if (isRight(mVertices[i])) { right.push_back(mVertices[i]); } else { left.push_back(mVertices[i]); } } }
void setDisplay(){ if (modechanged){ gotoXY(0,0); sprintf(cha, " Ustaw. wysw.");LcdString(cha, true); gotoXY(0,1); sprintf(cha, EMPTY_LINE);LcdString(cha, false); } gotoXY(0,1); sprintf(cha, "kontrast:");LcdString(cha,false); gotoXY(60,1); sprintf(cha, "%02i", contrast_val);LcdString(cha, (pos_setDisp==0)); gotoXY(0,2); sprintf(cha, "jasnosc:");LcdString(cha,false); gotoXY(60,2); sprintf(cha, "%02i", jasnosc_val);LcdString(cha, (pos_setDisp==1)); gotoXY(0,3); sprintf(cha, "OK");LcdString(cha,(pos_setDisp==2)); if (modechanged){ gotoXY(0,4); sprintf(cha, "<> poprz/nast");LcdString(cha); gotoXY(0,5); sprintf(cha, "^v wart +/-");LcdString(cha); modechanged=false; } if (pos_setDisp==0){ if (isUp()) { contrast_val=obetnij(contrast_val+1, 10, true); LcdInitialise(); } if (isDown()) { contrast_val=obetnij(contrast_val-1, 10, true); LcdInitialise(); } } else if (pos_setDisp==1){ if (isUp()) { jasnosc_val=obetnij(jasnosc_val+1, 50); analogWrite(11, jasnosc_val); } if (isDown()) { jasnosc_val=obetnij(jasnosc_val-1, 50); analogWrite(11, jasnosc_val); } } if (pos_setDisp==2){ if (isPressed()) { mode=1; modechanged=true; LcdClear(); return; } } if (isRight()) pos_setDisp++; if (isLeft()) pos_setDisp--; if (pos_setDisp>2) pos_setDisp=0; if (pos_setDisp<0) pos_setDisp=2; }
/* [ <expression> [, <actuals> ]] */ static Actuals *actuals(void) { if (isRight()) return 0; Actuals *p = NEW(Actuals); p->first = expression(); p->rest = 0; p->n = 1; if (isComma()) { consume(); p->rest = actuals(); p->n = p->rest->n + 1; } return p; }
void enregistrerDernierCapteurActif( Capteur &m_capteur = dernierCapteurActif, Capteur &m_capteurCote = dernierCapteurCoteActif ) { if(isRight() && !isLeft() && !isCenter()) { m_capteur = capteur_droit ; m_capteurCote = capteur_droit; } else if(!isRight() && isLeft() && !isCenter()) { m_capteur = capteur_gauche ; m_capteurCote = capteur_gauche; } else if(!isRight() && !isLeft() && isCenter()) { //m_capteurCote ne change pas m_capteur = capteur_centre ; } else if (isRight() && !isLeft() && isCenter()) { //droite et centre: on ne peut pas avoir gauche if (m_capteur == capteur_gauche || m_capteur == capteur_aucun) m_capteur = capteur_centre; m_capteurCote = capteur_droit; } else if (!isRight() && isLeft() && isCenter()) { //gauche et centre: on ne peut pas avoir droite if (m_capteur == capteur_droit || m_capteur == capteur_aucun) m_capteur = capteur_centre; m_capteurCote = capteur_gauche; } else if (!isRight() && !isLeft() && !isCenter()) { //aucun changement à l'état si on est dans l'état perdu //m_capteur = m_capteur; } else if (isRight() && isLeft() && isCenter()){ //les trois sont allumés: on change seulement si "aucun" if (m_capteur == capteur_aucun) m_capteur = capteur_centre; } else { //les deux extrémités sont allumés, mais pas le centre -- cas très rare, possible lorsqu'on tourne // et que les capteurs sont trop proches de l'intersection //m_capteur = m_capteur } }
void MenuSeperator::onSelected() { if (m_szSImg_right.size() == 0 || m_szSImg_left.size() == 0) return; if (isSelected()) { if (isRight()) m_imgBG->setImage(m_szSImg_right.c_str()); else m_imgBG->setImage(m_szSImg_left.c_str()); } else { m_imgBG->setImage(m_szImg.c_str()); } }
int main(){ int pflag=0; char password[1024] ; FILE *fp; LoadLibrary("user32.dll"); if(!(fp=fopen("pass.txt","rw+"))){ printf("file not open\n"); exit(0); } fscanf(fp,"%s",password); printf("%s\n",password); pflag=isRight(password); if(pflag){ printf("wrong password\n"); }else{ printf("Congratulations,you're right\n"); } fclose(fp); return 0 ; }
bool isValid(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function if (s.length()==0 || s.length()==1) return false; vector<char> stack; for (int i=0;i<s.length();i++) { if (isLeft(s[i])) stack.push_back(s[i]); else if (isRight(s[i]) && stack.size()>0) { if (isPair(stack.back(),s[i])) { stack.pop_back(); } else return false; } else return false; } if (stack.size()==0) return true; else return false; }
void Character::update(float delta, bool &isTouched, bool &ableToJump) { position = characterTexture->getPositionX(); position -= 300 * delta *changeDirect; if (characterTexture->getPositionX() < 800 - characterTexture->getContentSize().width / 2 && characterTexture->getPositionX() > characterTexture->getContentSize().width / 2 - 1 && isTouched == false) { position += 10 * changeDirect; } else { position -= 10 * changeDirect; if (isTouched == true) { if (changeDirect == 1) changeDirect = -1; else changeDirect = 1; } else if (isRight() == true) { changeDirect = -1; } else { changeDirect = 1; } isTouched = false; } characterTexture->setPositionX(position); if (characterTexture->getContentSize().height / 2 + 10 < characterTexture->getPositionY()) { ableToJump = false; } else { ableToJump = true; } }
void showMenu(){ if (isPressed()) { mode=pos_menu+2; modechanged=true; if (mode==5) mode=0; LcdClear(); return; } gotoXY(0,0); sprintf(cha, " Menu glowne ");LcdString(cha, true); gotoXY(0,1); sprintf(cha, " "); LcdString(cha, false); gotoXY(20,1); sprintf(cha, "budzik"); LcdString(cha, (pos_menu==0)); gotoXY(0,2); sprintf(cha, "ust."); LcdString(cha, (pos_menu==1)); gotoXY(30,2); sprintf(cha, " ^ "); LcdString(cha, false); gotoXY(50,2); sprintf(cha, "ust."); LcdString(cha, (pos_menu==2)); gotoXY(0,3); sprintf(cha, "czas"); LcdString(cha, (pos_menu==1)); gotoXY(30,3); sprintf(cha, "< > "); LcdString(cha, false); gotoXY(50,3); sprintf(cha, "wysw"); LcdString(cha, (pos_menu==2)); gotoXY(0,4); sprintf(cha, " v"); LcdString(cha, false); gotoXY(0,5); sprintf(cha, " "); LcdString(cha, false); gotoXY(20,5); sprintf(cha, "powrot"); LcdString(cha, (pos_menu==3)); if (isUp()) pos_menu=0; if (isDown()) pos_menu=3; if (isRight()) pos_menu=2; if (isLeft()) pos_menu=1; }
bool isValid(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function int n = s.size(); vector<char> stk; for (int i=0; i<n; ++i){ char c = s[i]; if (isRight(c)){ if (stk.empty()) return false; char stk_c = stk.back(); if (isPair(stk_c,c)){ stk.pop_back(); continue; }else{ return false; } }else{ stk.push_back(c); } } if (!stk.empty()) return false; else return true; }
int main() { int N; int i, j, k; //freopen("in.txt", "r", stdin); scanf("%d", &N); while(N) { answer = 0; for(i = 0; i < N; i++)for(j = 0; j < N; j++)scanf("%d", &matrix[i][j]); for (k = N; k > 2; k--) { if(!(k%2))continue; for(i = 0; i <= N-k; i++) { for(j = 0; j <= N-k; j++) { if(isRight(i, j, k)) { answer = k; printf("%d\n", k); goto GGG; } } } } GGG: if(!answer)printf("No solution\n"); scanf("%d", &N); } return 0; }
bool C4FoWBeam::MergeRight(int32_t x, int32_t y) { // Note: Right-merging is the most common and most important optimization. // This procedure will probably be *hammered* as a result. Worth inlining? assert(!isDirty()); assert(isRight(x, y)); // Calculate error. Note that simply summing up errors is not correct, // strictly speaking (as new and old error surfaces might overlap). Still, // this is quite elaborate already, no need to make it even more int32_t iErr = getDoubleTriangleSurface( getLeftEndX(), iLeftEndY, getRightEndX(), iRightEndY, x, y); if (iError + iErr > C4FoWMergeThreshold) return false; // Move right endpoint. iRightX = x; iRightY = y; iRightEndY = y; iError += iErr; return true; }
bool balayerZone(uint8_t vitesseMoteurDroit , uint8_t vitesseMoteurGauche , uint16_t rayonDeBalayage ) { bool ligneTrouvee = ( isLeft() || isRight() || isCenter() ); if (!ligneTrouvee) ligneTrouvee = balayer(vitesseMoteurDroit , rayonDeBalayage/2, direction_left); if (!ligneTrouvee) ligneTrouvee = balayer(vitesseMoteurGauche , rayonDeBalayage, direction_right); /* if (!ligneTrouvee) { while(!isCenter() && !isLeft() && !isRight()) reculerRobot(vitesseMoteurDroit , vitesseMoteurGauche); //ligneTrouvee demeure false arreterRobot(); } */ enregistrerDernierCapteurActif(dernierCapteurActif, dernierCapteurCoteActif); return ligneTrouvee ; }
const Right& right() const { Q_ASSERT(isRight()); return right_; }
Right& right() { Q_ASSERT(isRight()); return right_; }
void convertToRight(GrammarADT grammar) { int i; int ml = FALSE; char oldistiguished = getDistinguished(grammar); /*if the grammar is already right there is no * reason to convert it*/ if ( isRight(grammar) ) { return; } ProductionsADT productions = getProductions(grammar); int quantproductions = getQuant(productions); for(i = 0; i < quantproductions ; i++) { ProductionADT p1 = getProduction(productions, i); char first = getProductionComponent(p1, 0); char sec = getProductionComponent(p1, 1); char third = getProductionComponent(p1, 2); if(isNonTerminal(sec)) { addProduction(productions, newProduction(sec , third, first)); removeParticularProduction(productions,p1); } } setProductions(grammar, productions); /*a new nonTerminal should be created , * that joint the non terminals that were joined to lambda*/ char * leftnontermssymbols = NULL; int size=0; for(i=0; i < quantproductions; i++) { ProductionADT p1 = getProduction(productions, i); char first = getProductionComponent(p1, 0); char sec = getProductionComponent(p1, 1); char third = getProductionComponent(p1, 2); if(sec == LAMDA && third == LAMDA) { addChar(&leftnontermssymbols,&size,first); } } /*get a new distiguished symbol*/ char newsymbol = getNewSymbol(grammar); setDistinguished(grammar,newsymbol); /*generate new unitary productions*/ for(i=0; i<size; i++) { ProductionADT newprod = newProduction(newsymbol,leftnontermssymbols[i],LAMDA); //printProduction(newprod); addProduction(productions, newprod); } /*remove all old lambda productions*/ for(i=0; i<getQuant(productions); i++) { ProductionADT p = getProduction(productions,i); char sec = getProductionComponent(p,1); char third = getProductionComponent(p,2); /*if it is a lamda productions : delete*/ if( sec == LAMDA && third == LAMDA ) { removeParticularProduction(productions,p); } } if(!ml) { addProduction(productions, newProduction(oldistiguished, LAMDA, LAMDA)); } setProductions(grammar,productions); /*remove non terminals and terminals that are no longer there */ actualizeTerminals(grammar); actualizeNonTerminals(grammar); actualizeProductions(grammar); }