ozrotatepointz(Vector_t *v, int rot) { static long x, y; x = v->x; y = v->y; v->x = div256(x * icos(rot) - y * isin(rot)); v->y = div256(x * isin(rot) + y * icos(rot)); }
ozrotatepointy(Vector_t *_v, int rot) { static long x, z; register Vector_t *v=_v; x = v->x; z = v->z; v->x = div16384(x * icos(rot) - z * isin(rot)); v->z = div16384(x * isin(rot) + z * icos(rot)); }
double fpsin(double x) { static double z,t,flz; static unsigned n; z=x/M_2_PI; z=360.*(z-floor(z)); t=z-(flz=floor(z)); n=(unsigned int)flz; return M_RECIP_16384*((1-t)*isin(n)+t*isin(n+1)); }
void polygon(int cx, int cy, int corners, int r, int sa) { int i,k; k=sa; plot(cx+icos(k)*r/256,cy+isin(k)*r/256); for (i=0;i++<corners;k=(k+360/corners)%360) drawto(cx+icos(k)*r/256,cy+isin(k)*r/256); drawto(cx+icos(sa)*r/256,cy+isin(sa)*r/256); }
int isin(avl_any *t, any x, struct node *p) { if (p==NULL) return 0; else if (LT(x,p->item)) return isin(t, x, p->left); else if (LT(p->item,x)) return isin(t, x, p->right); else return 1; }
int bfs(int a, int b, int c, int d){ int i,j,k,x,y,oi[]={1,-1,0,0},oj[]={0,0,1,-1}; memset(dist, 0, sizeof(dist)); std::queue<P> q; q.push(P(a,b)); P p; dist[a][b] = 1; while(!q.empty()){ p = q.front();q.pop(); i = p.first; j = p.second; if(i == c && j == d) break; for(k=0;k<=3;k++){ x = i + oi[k]; y = j + oj[k]; if(dist[x][y])continue; if(!isin(x,y))continue; if(map[x][y])continue; dist[x][y] = dist[i][j] + 1; q.push(P(x,y)); } } return dist[c][d]-1; }
ParseTree* Parser::ASSIGN() { ParseTree* retTree = new ParseTree(); if((isin((*parser).get().string))) { (*retTree).SetLeaf1(ID_TERMINAL()->getLeaf()); if(!((*parser).get().token == ASSIGNMENT)) { ThrowParserError(); } if(!(*parser).Advance()) ThrowParserError(); (*retTree).SetLeaf2(EXPR()->getLeaf()); if(!((*parser).get().token == SEMI_COLON)) { ThrowParserError(); } if(!(*parser).Advance()) ThrowParserError(); } else { ThrowParserError(); } return retTree; }
int RingToAngle(int x, int y, int angle, int speed) { if (speed <= 0) speed = 1; manage->New.Data.hitAtt = MEnemy; manage->New.Data.hitMask = MPlayer | MPShot; manage->New.Data.X = x; manage->New.Data.Y = y; manage->New.Data.HP = 1; manage->New.Data.Point = 0; manage->New.Data.Angle = angle; manage->New.Data.Speed = speed; manage->New.Data.Cnt[0] = x << 8; manage->New.Data.Cnt[1] = y << 8; manage->New.Data.Cnt[2] = icos(angle); manage->New.Data.Cnt[3] = isin(angle); manage->New.Data.Cnt[4] = 0; manage->New.Data.EnemyAtt = NullDel; manage->New.Data.Width = 28; manage->New.Data.Height = 28; manage->New.Grp.image = ERingImage; return NewObj(MEnemy,EnemyShotAct,DeleteHit,DrawImage); }
/* enemy shot */ void ShotToAngle(int x, int y, int angle, int speed) { int i; if (manage->EnemyNum >= manage->EnemyMax) return; if (speed <= 0) speed = 1; for (i=1; i<manage->EnemyMax; i++) { if (manage->enemy[i]->Data.used == False) { manage->EnemyShot.Data.X = x; manage->EnemyShot.Data.Y = y; manage->EnemyShot.Data.Angle = angle; manage->EnemyShot.Data.Speed = speed; manage->EnemyShot.Data.Cnt[0] = x << 8; manage->EnemyShot.Data.Cnt[1] = y << 8; manage->EnemyShot.Data.Cnt[2] = icos(angle); manage->EnemyShot.Data.Cnt[3] = isin(angle); manage->enemy[i]->Data = manage->EnemyShot.Data; manage->enemy[i]->Grp = manage->EnemyShot.Grp; manage->enemy[i]->Action = EnemyShotAct; manage->enemy[i]->Realize = DrawImage; manage->enemy[i]->Hit = NullDelHit; manage->EnemyNum++; return; } } }
void PlayerShot2(int x, int y, int speed, int angle) { manage->New.Data.hitAtt = MPShot; manage->New.Data.hitMask = MEnemy; manage->New.Data.X = x; manage->New.Data.Y = y; manage->New.Data.Attack = 1; manage->New.Data.Speed = speed; manage->New.Data.Angle = angle; manage->New.Data.EnemyAtt = NullDel; manage->New.Data.Width = 12; manage->New.Data.Height = 16; manage->New.Data.Cnt[0] = x << 8; manage->New.Data.Cnt[1] = y << 8; manage->New.Data.Cnt[2] = icos(angle); manage->New.Data.Cnt[3] = isin(angle); manage->New.Data.Cnt[4] = 0; manage->New.Grp.image = PShot2Image; NewObj(MPShot,PlayerShotAct1,PlayerShotHit1,DrawImage); }
int main( int argc, char **argv ) { int i = 1, j = 0, sch = 0; while ( i < argc ) { if ( (argv[i][0] == '-') && isin(argv[i][1],"en-") && getopts(argv[i]+1) ) i++; if ( stopargs ) break; } char skip = 0; while ( i < argc ) { if ( !(opt&O_ESC) ) { fputs(argv[i],stdout); putchar(((i+1)==argc)?((opt&O_NONL)?'\0':'\n'):' '); i++; continue; } j = skip = 0; while ( !skip ) { sch = descape(argv[i]+j); j += sch; if ( sch == -1 ) return 0; if ( !sch ) skip = 1; } putchar((i<(argc-1))?' ':'\n'); i++; } return 0; }
////////////////////////////////////// // initialize matching terms iterator // int DbIntlog::Search(Term t, DbEntryIter &iter, DbIntlog *dbs) { #ifdef _DEBUG CCP tstring = t.get_funct(); #endif DbEntry e = DbEntry(t.get_funct(), t.get_arity()), *dbe = isin(e); if (!dbe) { if (dbs == 0 || (dbe = dbs->isin(e)) == 0 || dbe->vProp != DbEntry::dynamic) { iter.pcc = 0; iter.own = iter.mod = 0; return 0; } iter.mod = iter.own = dbs; } else { iter.mod = this; iter.own = dbs; } // initialize for later search iter.pcc = (e_DbList*)dbe->get_first()->fix_clause(dbs); iter.pcp = 0; return 1; }
static long icos(int const deg) { /*---------------------------------------------------------------------------- Return cosine of an angle in integral degrees. The value returned is 65536 times the cosine -----------------------------------------------------------------------------*/ return isin(deg + 90); }
// :kenny.chatspike.net 320 Om Epy|AFK :is a Secure Connection virtual void OnWhois(userrec* source, userrec* dest) { // Bugfix, only send this numeric for *our* SSL users if(dest->GetExt("ssl", dummy) || (IS_LOCAL(dest) && isin(dest->GetPort(), listenports))) { source->WriteServ("320 %s %s :is using a secure connection", source->nick, dest->nick); } }
/* If no solution, check: 1. ret.size() < 3 * Or more precisely, 2. interPnt(ret[0], ret[1]) * in all the lines. (use (l.S - l.F).cross(p - l.F) > 0 */ vector<Line> halfPlaneInter(vector<Line> lines) { int sz = lines.size(); vector<double> ata(sz), ord(sz); for (int i=0; i<sz; i++) { ord[i] = i; pdd d = lines[i].S - lines[i].F; ata[i] = atan2(d.y, d.x); } sort(ALL(ord), [&](int i, int j) { if (abs(ata[i] - ata[j]) < EPS) { return cross(lines[i].S, lines[j].S, lines[i].F) < 0; } return ata[i] < ata[j]; }); vector<Line> fin; for (int i=0; i<sz; i++) { if (!i or fabs(ata[ord[i]] - ata[ord[i-1]]) > EPS) { fin.PB(lines[ord[i]]); } } deque<Line> dq; for (int i=0; i<SZ(fin); i++) { while(SZ(dq) >= 2 and not isin(fin[i], dq[SZ(dq)-2], dq[SZ(dq)-1])) { dq.pop_back(); } while(SZ(dq) >= 2 and not isin(fin[i], dq[0], dq[1])) { dq.pop_front(); } dq.push_back(fin[i]); } while (SZ(dq) >= 3 and not isin(dq[0], dq[SZ(dq)-2], dq[SZ(dq)-1])) { dq.pop_back(); } while (SZ(dq) >= 3 and not isin(dq[SZ(dq)-1], dq[0], dq[1])) { dq.pop_front(); } vector<Line> res(ALL(dq)); return res; }
void squeeze(char s1[],char s2[]) { int i=0,j=0; for(; s1[i]!='\0'; i++) { if(!isin(s2,s1[i])) s1[j++]=s1[i]; } s1[j]='\0'; }
void pamd_text(tuple** const tuples, int const cols, int const rows, int const depth, sample const maxval, pamd_point const pos, int const height, int const angle, const char * const sArg, pamd_drawproc drawProc, const void * const clientdata) { /*---------------------------------------------------------------------------- Draw the zero-terminated string 'sArg', with its baseline starting at point 'pos', inclined by 'angle' degrees to the X axis, with letters 'height' tuples high (descenders will extend below the baseline). We pass the supplied drawproc and clientdata to pamd_linep, which performs the actual drawing. There may be multiple lines of text. The baseline of the topmost line starts at 'pos'. -----------------------------------------------------------------------------*/ const struct ppmd_font * const fontP = ppmd_get_font(); long rotsin, rotcos; pamd_point p; const char * s; pamd_validatePoint(pos); p = makePoint(0, 0); rotsin = isin(-angle); rotcos = icos(-angle); for (s = &sArg[0]; *s; ) { unsigned char const ch = *s++; if (ch >= fontP->header.firstCodePoint && ch < fontP->header.firstCodePoint + fontP->header.characterCount) { const struct ppmd_glyph * const glyphP = &fontP->glyphTable[ch - fontP->header.firstCodePoint]; unsigned int cursorAdvance; pamd_validatePoint(p); drawGlyph(glyphP, p, tuples, cols, rows, depth, maxval, height, pos, rotcos, rotsin, drawProc, clientdata, &cursorAdvance); p.x += cursorAdvance; } else if (ch == '\n') { /* Move to the left edge of the next line down */ p.y += Scalef + Descend; p.x = 0; } } }
int main(int argc,char* argv[]) { stack s; char* left= "([{"; char* right= ")]}"; char ch,ch_prior; bool flag = true; stack_init(&s); while(true) { ch=getchar(); if(ch =='\n') break; if(isin(ch,left)) push(&s,&ch); else if(isin(ch,right)) { if(gettop(&s,&ch_prior)&&match(ch_prior,ch)) pop(&s,&ch); else { flag=false; break; } } } if(!stackempty) flag = false; if (flag==true) puts("yes"); else puts("no"); return 0; }
void initdots(struct dots *d, int x0, int y0, int rx, int ry, int i0, int j0) { int i; for(i=0; i<256; i++) { d->x[i] = x0 + icos(i, rx); d->y[i] = y0 + isin(i, ry); } d->i = (i0 & 0xff); d->j = (j0 & 0xff); }
void draw_marchingborder() { for(int i = -1, f = 0; i < 256; i+=8, f++) { int16_t x = 128 + isin(i); int16_t y = 128 + icos(i); if (i == -1 || ((f + textangle/4) % 2 == 0)) { trazador.MoveTo(x, y); } else { trazador.LineTo(x,y); } } }
ParseTree* Parser::ID_LIST(bool in) { ParseTree* retTree = new ParseTree(); if(!((*parser).get().token == ID)) { ThrowParserError(); } if(in) { if(!isin((*parser).get().string)) { ThrowParserError(); } } else { if(isin((*parser).get().string)) { ThrowParserError(); } } (*retTree).SetLeaf1(ID_TERMINAL()->getLeaf()); if((*parser).get().token == COMMA) { if(!(*parser).Advance()) ThrowParserError(); (*retTree).SetLeaf2(ID_LIST(in)->getLeaf()); (*retTree).setAlt(2); } else { (*retTree).setAlt(1); } return retTree; }
char *strtok(char *str, const char *delim) { static char* s; if (str != NULL) { s = str; // make sure to skip preceding delims while (isin(delim, *s)) { s++; } } else if (*s == '\0') { // if we're at the end of s return NULL; } char *ret = s; int i; for (i = 0; s[i] != '\0'; i++) { if (isin(delim, s[i])) { break; } } // if we found a delim if (s[i] != '\0') { // move through consecutive delims do { i++; s[i-1] = '\0'; } while (isin(delim, s[i]) && s[i] != '\0'); } // make sure ret wasn't inside a delim // do we still need this??? while (*ret == '\0') { ret++; } s = &s[i]; return ret; }
////////////////////////////////// // seek entry (if !found, insert) // DbEntry *DbIntlog::make_entry(kstring f, int arity) { DbEntry e(f, arity), *dbe = isin(&e); if (!dbe) { dbe = new DbEntry(f, arity); insert(dbe); } else if (dbe->arity == -1) dbe->arity = arity; return dbe; }
virtual void OnCleanup(int target_type, void* item) { if(target_type == TYPE_USER) { userrec* user = (userrec*)item; if(user->GetExt("ssl", dummy) && IS_LOCAL(user) && isin(user->GetPort(), listenports)) { // User is using SSL, they're a local user, and they're using one of *our* SSL ports. // Potentially there could be multiple SSL modules loaded at once on different ports. ServerInstance->Log(DEBUG, "m_ssl_openssl.so: Adding user %s to cull list", user->nick); culllist->AddItem(user, "SSL module unloading"); } } }
ParseTree* Parser::ID_TERMINAL() { ParseTree* retTree = new ParseTree(); (*retTree).setToken((*parser).get()); if(!(isin((*parser).get().string))) { symbolList[symbolIndex].ID = (*parser).get().string; symbolList[symbolIndex].SYMBOL_INIT_FLAG = false; symbolIndex++; } if(!(*parser).Advance()) ThrowParserError(); return retTree; }
void get_opt(t_pf *pf, t_nd *nd) { while (isin(OPT, *(pf->format))) { if (*(pf->format) == '#') nd->opt |= OPT_SHARP; if (*(pf->format) == '-') nd->opt |= OPT_MINUS; if (*(pf->format) == ' ') nd->opt |= OPT_SPACE; if (*(pf->format) == '+') nd->opt |= OPT_PLUS; if (*(pf->format) == '0') nd->opt |= OPT_ZERO; pf->format++; } }
void draw_spiral() { for(int i = -1; i < 256; i+=8) { int16_t x = isin(a); int16_t y = icos(a); x = 128 + (x * scale)/128; y = 128 + (y * scale)/128; if (i == -1) { trazador.MoveTo(x, y); } else { trazador.LineTo(x,y); } scale+=4; a+=8; } }
void word::insert(string wword, string url, string title) { //cout << "word::insert(" << wword << ", " << url << ", " << title <<")" << endl; word* w = new word(wword, url, title); if(word::head == 0) { //empty list head = w; //url } else { word* temp = isin(*w); //cout << "isin() = " << temp << endl; if(temp != 0) temp->slist->insert(url, title); else { w->nextw = head; head = w; } } }// end insert
ParseTree* Parser::FACTOR() { ParseTree* retTree = new ParseTree(); if((*parser).get().token == CONST) { (*retTree).setAlt(1); (*retTree).SetLeaf1(CONST_TERMINAL()->getLeaf()); } else if((*parser).get().token == ID) { (*retTree).setAlt(2); if(!isin((*parser).get().string)) { ThrowParserError(); } (*retTree).SetLeaf1(ID_TERMINAL()->getLeaf()); } else if((*parser).get().token == MINUS) { (*retTree).setAlt(3); if(!(*parser).Advance()) ThrowParserError(); (*retTree).SetLeaf1(FACTOR()->getLeaf()); } else if(!(*parser).get().token == LEFT_PAREN) { (*retTree).setAlt(4); if(!(*parser).Advance()) ThrowParserError(); (*retTree).SetLeaf1(EXPR()->getLeaf()); if(!((*parser).get().token == RIGHT_PAREN)) { ThrowParserError(); } if(!(*parser).Advance()) ThrowParserError(); } else { ThrowParserError(); } return retTree; }
int main() { int itr; int nCount; /* 문제의 테스트 케이스 */ scanf("%d", &nCount); /* 테스트 케이스 입력 */ for(itr=0; itr<nCount; itr++) { printf("#testcase%d\n",itr+1); scanf("%d %d", &start, &r); // printf("%d\n", func(start, r)); // printf("%d ", start); top = -1; int start_cpy = start; while(1){ int t = func(start_cpy, r); int search_index = isin(t); if(search_index == -1){ push(t); } else{ printf("%d\n", search_index+1); break; } start_cpy = t; // printf("%d ", t); } // printf("\n"); } return 0; /* 반드시 return 0으로 해주셔야합니다. */ }