void com1(int k) { struct item* p; p = sp[-2]; p->index = idx.idx[k]; if (getdat(p)) { p = sp[-3]; p->index = access(); putdat(sp[-1], getdat(p)); } }
int main(int foo, char *bar[]) { if (foo < 2) { puts("Give me a Sudoku file"); return -1; } input(bar[1]); getdat(); if (fill_min() != -1) { if (chkdat() != 0) fprintf(stderr, "fill_min: Wrong solution\n"); output(DAT, "output.min"); } else fprintf(stderr, "fill_min: failed\n"); /* int anti_shit = 10, c = 0; while (1) { if (++c > anti_shit) { fprintf(stderr, "Go green :D...\n"); break; } if (fill_next(bar[1], bar[2]) != -1) { if (chkdat() != 0) fprintf(stderr, "fill_next: Wrong solution\n"); printf("# %d\n", c); output(DAT, bar[1]); logdat(DAT, "log"); } else break; } */ getdat(); if (fill_max() != -1) if (chkdat() != 0) fprintf(stderr, "fill_max: Wrong solution\n"); output(DAT, "output.max"); else
//isRNA = true is RNA parameters should be loaded // = false for DNA parameters CFoldDoc::CFoldDoc(bool isRNA, char *datapath, CWinApp *pMainFrame1, char* startpath1, bool fold, bool *Savefile, bool PF) { char loop[maxfil],stackf[maxfil], tstackh[maxfil], tstacki[maxfil], tloop[maxfil], miscloop[maxfil], danglef[maxfil], int22[maxfil], int21[maxfil],coax[maxfil], tstackcoax[maxfil],coaxstack[maxfil], tstack[maxfil], tstackm[maxfil],triloop[maxfil],int11[maxfil],hexaloop[maxfil], tstacki23[maxfil],tstacki1n[maxfil]; ISRNA = isRNA; Datapath = datapath; getdat(loop, stackf, tstackh, tstacki, tloop, miscloop, danglef, int22, int21,coax, tstackcoax, coaxstack, tstack, tstackm, triloop, int11, hexaloop, tstacki23, tstacki1n, datapath, isRNA); if (opendat(loop, stackf, tstackh, tstacki, tloop, miscloop, danglef, int22, int21,coax, tstackcoax, coaxstack, tstack, tstackm, triloop, int11,hexaloop,tstacki23, tstacki1n, &data)) OK = true; else OK = false; pMainFrame = pMainFrame1; startpath = startpath1; if (!PF) { if (isRNA&&fold) { SetTitle("RNA Fold"); } else if (fold) SetTitle("DNA Fold"); else if (isRNA) SetTitle("RNA Efn2"); else SetTitle("DNA Efn2"); } else { if (isRNA&&fold) { SetTitle("RNA Partition Function"); } else if (fold) SetTitle("DNA Partition Function"); } filenamedefined = false; savefile = Savefile; T = (float) 310.15; maximuminternalloopsize = 30; }
void index1(int i, int f) { struct item* p; int j, k; if (i >= idx.rank) { switch (f) { case 0: p = sp[-2]; p->index = access(); putdat(sp[-1], getdat(p)); return; case 1: datum = getdat(sp[-idx.rank - 3]); case 2: p = ((SymTabEntry*)sp[-2])->itemp; p->index = access(); putdat(p, datum); return; } } p = sp[-i - 3]; if (p->itemType == EL) { for (j = 0; j < idx.dim[i]; j++) { idx.idx[i] = j; index1(i + 1, f); } return; } p->index = 0; for (j = 0; j < p->size; j++) { k = fix(getdat(p)) - iorigin; if (k < 0 || k >= idx.dim[i]) error(ERR_index, ""); idx.idx[i] = k; index1(i + 1, f); } }
ex_dtrn() { struct item *p, *q; int i; p = fetch2(); q = sp[-2]; if(p->rank > 1 || p->size != q->rank) error("tranpose C"); for(i=0; i<p->size; i++) idx.idx[i] = fix(getdat(p)) - thread.iorg; pop(); trn0(); }
index1(i, f) { struct item *p; int j, k; if(i >= idx.rank) { switch(f) { case 0: p = sp[-2]; p->index = access_(); putdat(sp[-1], getdat(p)); return; case 1: datum = getdat(sp[-idx.rank-3]); case 2: p = ((struct nlist *)sp[-2])->itemp; p->index = access_(); putdat(p, datum); return; } } p = sp[-i-3]; if(p->type == EL) { for(j=0; j<idx.dim[i]; j++) { idx.idx[i] = j; index1(i+1, f); } return; } p->index = 0; for(j=0; j<p->size; j++) { k = fix(getdat(p)) - thread.iorg; if(k < 0 || k >= idx.dim[i]) error("subscript X"); idx.idx[i] = k; index1(i+1, f); } }
void comk(int k) { struct item* p; data d; int i, dk, ndk; p = sp[-1]; bidx(sp[-2]); /* "getdat" returns the value of the data item which * it is called to fetch. If this is non-zero, just * use the existing data on the stack (an example in * APL would be "x/y" where x != 0. If this is zero, * the result is the null item, which is created by * "newdat" and pushed on the stack. */ if (p->rank == 0 || (p->rank == 1 && p->size == 1)) { if (getdat(p)) { pop(); return; } p = newdat(idx.type, 1, 0); pop(); pop(); *sp++ = p; return; } if (idx.rank == 0 && p->rank == 1) { /* then scalar right arg ok */ dk = p->dim[0]; ndk = 0; for (i = 0; i < dk; i++) { if (getdat(p)) ndk++; } p = newdat(idx.type, 1, ndk); d = getdat(sp[-2]); for (i = 0; i < ndk; i++) putdat(p, d); pop(); pop(); *sp++ = p; return; } if (k < 0 || k >= idx.rank) error(ERR_index, ""); dk = idx.dim[k]; if (p->rank != 1 || p->size != dk) error(ERR_length, ""); ndk = 0; for (i = 0; i < dk; i++) { if (getdat(p)) ndk++; } p = newdat(idx.type, idx.rank, (idx.size / dk) * ndk); copy(IN, (char*)idx.dim, (char*)p->dim, idx.rank); p->dim[k] = ndk; *sp++ = p; indexIterateInit(&idx); while (indexIterate(&idx)) { com1(k); } sp--; pop(); pop(); *sp++ = p; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////// // Ёта функци¤ создаетс¤ в отдельном потоке и // обсуживает очередного подключившегос¤ клиента // независимо от остальных unsigned _stdcall SexToClient(void *client_socket) { number++; int mynum = number; _Player.push_back(Player()); SOCKET my_sock; my_sock = ((SOCKET *)client_socket)[0]; char buff[1024]; std::string data="",statstr=""; std::vector<int> mobmassindex(Mobs.size()); // цикл эхо-сервера: прием строки от клиента и // возвращение ее клиенту int bytes_recv; while ((bytes_recv =recv(my_sock, &buff[0], sizeof(buff), 0))&& (bytes_recv != SOCKET_ERROR)) { statstr = ""; std::string s(buff, bytes_recv); data = s; EnterCriticalSection(®en); if (getdat(data) == "MyUPD") { rem(data); _Player[mynum].SetPositionX(atof(getdat(data).c_str())); rem(data); _Player[mynum].SetPositionY(atof(getdat(data).c_str())); rem(data); _Player[mynum].SetPositionZ(atof(getdat(data).c_str())); rem(data); _Player[mynum].SetRotationY(atof(getdat(data).c_str())); } if (getdat(data) == "Resurrection"){ _Player[mynum].Resurrection(); } if (getdat(data) == "UseSkill" && _Player[mynum].Live()) { _Player[mynum].status = NONE; rem(data); if (getdat(data) == "Blink") { _Player[mynum].Blink(); _Player[mynum].CauseDamage(15); } } if (getdat(data) == "Attack" && _Player[mynum].Live()) { _Player[mynum].status = ATTACK; rem(data); _Player[mynum].targetnumber = atoi(getdat(data).c_str()); } if (getdat(data) == "Motion" && _Player[mynum].Live()) { _Player[mynum].status = NONE; rem(data); statstr = "Motion|" + getdat(data) + "|"; rem(data); statstr = statstr + getdat(data) + "|"; rem(data); statstr = statstr + getdat(data) + "|"; } if (_Player[mynum].status == ATTACK){ if (distance(_Player[mynum].Position(), Mobs[_Player[mynum].targetnumber].Position()) <= 1.5f) { if (Mobs[_Player[mynum].targetnumber].Live()){ _control.Attack(0, mynum); } else{ _Player[mynum].status = NONE; } } else { statstr = "Persecution|" + std::to_string(_Player[mynum].targetnumber) + "|"; } } int kkkl = 0; for (int j = 0; j < Mobs.size(); j++){ if (fabs(Mobs[j].GetPositionX() - _Player[mynum].GetPositionX()) <= _Player[mynum].vision_range){ if (fabs(Mobs[j].GetPositionZ() - _Player[mynum].GetPositionZ()) <= _Player[mynum].vision_range){ if (distance(Mobs[j].Position(), _Player[mynum].Position()) <= _Player[mynum].vision_range){ mobmassindex[kkkl] = j; kkkl++; } } } } s = "AllUPD|" + statstr + std::to_string(_Player[mynum].GetPositionX()) + "|" + std::to_string(_Player[mynum].GetPositionY()) + "|" + std::to_string(_Player[mynum].GetPositionZ()) + "|" + std::to_string(_Player[mynum].GetHP()) + "|" + std::to_string(_Player[mynum].GetMaxHP()) + "|" + std::to_string(_Player[mynum].Live()) + "|" + std::to_string(kkkl) + "|"; for (int j = 0; j < kkkl; j++) { s = s + std::to_string(mobmassindex[j]) + "|"; } for (int j = 0; j < kkkl; j++) { s = s + std::to_string(mobmassindex[j]) + "|" + Mobs[mobmassindex[j]].GetName() + "|" + std::to_string(Mobs[mobmassindex[j]].GetPositionX()) + "|" + std::to_string(Mobs[mobmassindex[j]].GetPositionY()) + "|" + std::to_string(Mobs[mobmassindex[j]].GetPositionZ()) + "|" + std::to_string(Mobs[mobmassindex[j]].GetRotationY()) + "|" + std::to_string(Mobs[mobmassindex[j]].GetHP()) + "|" + std::to_string(Mobs[mobmassindex[j]].GetMaxHP()) + "|"; } s = s + std::to_string(_Player.size() - 1) + "|"; for (int j = 0; j < _Player.size(); j++) { if (j != mynum){ s = s + std::to_string(j) + "|" + std::to_string(_Player[j].GetPositionX()) + "|" + std::to_string(_Player[j].GetPositionY()) + "|" + std::to_string(_Player[j].GetPositionZ()) + "|" + std::to_string(_Player[j].GetRotationY()) + "|" + std::to_string(_Player[j].GetHP()) + "|" + std::to_string(_Player[j].GetMaxHP()) + "|"; } } LeaveCriticalSection(®en); send(my_sock, &s[0], s.length(), 0); } // если мы здесь, то произошел выход из цикла по // причине возращени¤ функцией recv ошибки Ц // соединение клиентом разорвано nclients--; // уменьшаем счетчик активных клиентов printf("-disconnect\n"); PRINTNUSERS // закрываем сокет closesocket(my_sock); return 0; }
int IDCAgetdat(idc_handle_t fh, int ifsn, int nos, int** value, int dims_array[], int* ndims) { return getdat(fh, ifsn, nos, value, dims_array, ndims, 1); }
/////////////////////////////////////////////////////////////////////////////// // Run calculations. /////////////////////////////////////////////////////////////////////////////// void ShapeKnots_Interface::run() { char loop[maxfil],stackf[maxfil],tstackh[maxfil],tstacki[maxfil], tloop[maxfil],miscloop[maxfil],danglef[maxfil],int22[maxfil], int21[maxfil],coax[maxfil],tstackcoax[maxfil],coaxstack[maxfil],tstack[maxfil],tstackm[maxfil],triloop[maxfil],int11[maxfil],hexaloop[maxfil], tstacki23[maxfil], tstacki1n[maxfil],datapath[maxfil],*pointer; #ifdef OUTPUT_TO_SCREEN cout << "############################################\n"; cout << " ShapeKnots Folding Started\n"; cout << "############################################\n"; cout << "Reading Files..." << flush ; #endif datatable *data=new datatable; pointer = getenv("DATAPATH"); if (pointer!=NULL){ strcpy(datapath,pointer);//open the data files -- must reside in the DATAPATH strcat(datapath,"/");//The path to DATAPATH has to end with '/' } else strcpy(datapath,"");//open the data files -- must reside in the same directory as the executable //open the thermodynamic data tables getdat (loop, stackf, tstackh, tstacki,tloop, miscloop, danglef, int22, int21,coax, tstackcoax,coaxstack, tstack, tstackm, triloop, int11, hexaloop, tstacki23, tstacki1n, datapath, true);//the true indicates RNA parameters if (opendat (loop,stackf,tstackh,tstacki,tloop,miscloop,danglef,int22,int21, coax,tstackcoax,coaxstack,tstack,tstackm,triloop,int11,hexaloop,tstacki23,tstacki1n,data)==0) { cerr << "A data file was lost"; } //Check if the files exist: //Check if the sequence file exists ifstream inseq(seqFile.c_str()); if(!inseq) { cerr << " SEQUENCE INPUT FILE NOT FOUND\n"; delete data; inseq.close(); return; } structure *ct=new structure;//initialise the structure class 'ct' //Store the path to output CT file ct->openseq(seqFile.c_str());//open the sequence //If the user has specified a SHAPE restraints file, read the file. if(!SHAPEFile.empty()){ //Read in the shape data file and convert the data to a linear penalty ct->SHAPEslope = slope*conversionfactor;//read the slope ct->SHAPEintercept = intercept*conversionfactor;//read the intercept ct->ReadSHAPE(SHAPEFile.c_str()); } //If the user has specified a DSHAPE restraints file, read the file. if(!DSHAPEFile.empty()){ //Read in the shape data file and convert the data to a linear penalty ct->SHAPEslope = Dslope*conversionfactor;//read the slope ct->SHAPEintercept = 0;//read the intercept ct->ReadSHAPE(DSHAPEFile.c_str(),"diffSHAPE"); } //If the user has specified a DMS restraints file, read the file. if(!DMSFile.empty()){ //Read in the dms data file and convert the data to a linear penalty ct->ReadSHAPE(DMSFile.c_str(),"DMS"); } //Read the Double-strand offset data into 'ct' if(!doubleOffsetFile.empty()) ct->ReadOffset(NULL,doubleOffsetFile.c_str());//read the offset data //Read the Single-strand offset data into 'ct' if(!singleOffsetFile.empty()) ct->ReadOffset(NULL,singleOffsetFile.c_str());//read the offset data //The rest of the code is located in the 'pseudoknot' function. pseudoknot(ct, data, InMaxStructures, InPercent, InWindowSize, ctFile, P1, P2, slope, intercept, DMSFile, SHAPEFile, Dslope, DSHAPEFile, doubleOffsetFile, OutPercent, OutWindowSize, OutMaxStructures, ifWindowOptions, finallistSize); delete ct; delete data; }
ex_index() { struct item *p, *q; int i, j, f, n, lv; n = *pcp++; f = *pcp; p = sp[-1]; if(f == ASGN) { pcp++; if(p->type != LV) error("indexed assign value"); if(((struct nlist *)p)->use != DA) fetch1(); /* error("used before set"); */ q = ((struct nlist *)p)->itemp; } else q = fetch1(); if(q->rank != n) error("subscript C"); idx.rank = 0; for(i=0; i<n; i++) { p = sp[-i-2]; if(p->type == EL) { idx.dim[idx.rank++] = q->dim[i]; continue; } p = fetch(p); sp[-i-2] = p; for(j=0; j<p->rank; j++) idx.dim[idx.rank++] = p->dim[j]; } size(); if(f == ASGN) { p = fetch(sp[-n-2]); sp[-n-2] = p; if (p->size > 1) { if(idx.size != p->size) error("assign C"); f = 1; /* v[i] <- v */ } else { if (idx.size && !p->size) error("assign C"); /* Note -- for idx.size = 0, no assign occurs * anyway, so it is safe to set "datum" to 0 */ datum = p->size ? getdat(p) : 0; f = 2; /* v[i] <- s */ } ex_elid(); } else { p = newdat(q->type, idx.rank, idx.size); copy(IN, idx.dim, p->dim, idx.rank); *sp++ = p; f = 0; /* v[i] */ } bidx(q); index1(0, f); if(f == 0) { p = sp[-1]; sp--; for(i=0; i<=n; i++) pop(); *sp++ = p; } else { pop(); /* pop ELID */ sp--; /* skip over LV */ for(i=0; i<n; i++) pop(); } }
void ex_index() { struct item *p, *q; int i, j, f, n; n = *gsip->ptr++; f = *gsip->ptr; p = sp[-1]; if (f == ASGN) { gsip->ptr++; if (p->itemType != LV) error(ERR_value, "not a local variable"); if (((SymTabEntry*)p)->entryUse != DA) fetch1(); q = ((SymTabEntry*)p)->itemp; } else q = fetch1(); if (q->rank != n) error(ERR_index, ""); idx.rank = 0; for (i = 0; i < n; i++) { p = sp[-i - 2]; if (p->itemType == EL) { idx.dim[idx.rank++] = q->dim[i]; continue; } p = fetch(p); sp[-i - 2] = p; for (j = 0; j < p->rank; j++) idx.dim[idx.rank++] = p->dim[j]; } size(); if (f == ASGN) { p = fetch(sp[-n - 2]); sp[-n - 2] = p; if (p->size > 1) { if (idx.size != p->size) error(ERR_length, ""); f = 1; /* v[i] <- v */ } else { if (idx.size && !p->size) error(ERR_length, ""); /* Note -- for idx.size = 0, no assign occurs * anyway, so it is safe to set "datum" to 0 */ datum = p->size ? getdat(p) : 0; f = 2; /* v[i] <- s */ } ex_elid(); } else { p = newdat(q->itemType, idx.rank, idx.size); copy(IN, (char*)idx.dim, (char*)p->dim, idx.rank); *sp++ = p; f = 0; /* v[i] */ } bidx(q); index1(0, f); if (f == 0) { p = sp[-1]; sp--; for (i = 0; i <= n; i++) pop(); *sp++ = p; } else { pop(); /* pop ELID */ sp--; /* skip over LV */ for (i = 0; i < n; i++) pop(); } }
void beforegame() /******游戏主界面*******/ { int i,j; fire(); ShowBmp256(70,65,".\\source\\login.bmp",1,0); InitGraph(); star=malloc(sizeof(struct STAR)*STARNUM); initstar(star); InitMouse(0,0,maxx,maxy); getdat(); handler=getvect(0x1c); mousex=getmaxx()/2; mousey=getmaxy()/2; logo=bmp_to_dat(".\\source\\snooker.bmp"); vs1=bmp_to_dat(".\\source\\head0.bmp"); vs2=bmp_to_dat(".\\source\\head1.bmp"); play(1); for (i=0;i<3;i++) { putimage(0,0,logo,NOT_PUT); for (j=20;j<=1000;j+=10) { delay(1000); } delay(3000); putimage(0,0,logo,COPY_PUT); for (j=1000;j>=20;j-=10) { delay(2000); } delay(3000); } putimage(0,0,logo,COPY_PUT); for (i=0;i<STARNUM;i++) drawstar(star); outchinese(400,80,s_cn,EOF,4,2); putimage(300,280,vs1,COPY_PUT); putimage(520,280,vs2,COPY_PUT); settextstyle(1,0,12); setcolor(GREEN); outtextxy(380,260,"Vs"); drawmouse(mousex,mousey); play(2); drawmenu(mm); while(1) { while(bioskey(1)!=0) getch(); position(1); mm=fill(); drawmouse(mousex,mousey); if (button==1) { switch (mm) { case 0: { free(logo); free(star); cleardevice(); return; } case 1: { practice(); restore(); break; } case 2: { noplay(); option(); break; } case 3: { noplay(); toprank(); restore(); break; } case 4: { if (Music_on==1) play(0); showhelp(); break; } case 5: { position(0); End(1); drawmouse(mousex,mousey); break; } } } button=0; } }