static gmx_bool xyz_next_x(t_trxstatus *status, FILE *fp, const output_env_t oenv, real *t, int natoms, rvec x[], matrix box) /* Reads until a new x can be found (return TRUE) * or eof (return FALSE) */ { real pt; pt = *t; while (!bTimeSet(TBEGIN) || (*t < rTimeValue(TBEGIN))) { if (!do_read_xyz(status, fp, natoms, x, box)) { return FALSE; } printcount(status, oenv, *t, FALSE); *t += status->DT; pt = *t; } if (!bTimeSet(TEND) || (*t <= rTimeValue(TEND))) { if (!do_read_xyz(status, fp, natoms, x, box)) { printlast(status, oenv, *t); return FALSE; } printcount(status, oenv, *t, FALSE); pt = *t; *t += status->DT; return TRUE; } printlast(status, oenv, pt); return FALSE; }
int main() { char input[100]; int i=0, len,index; while(scanf("%s",input)!= EOF) { //printf("%s",input); len = strlen(input); i++; /* rem = len % 9; if(rem != 0) printfront(input,rem); */ index = 0; count = len / 9; /* for(i=0;i<count;i++) {*/ printf("%4d.",i); if(count != 0) { printfront(input+index,len - 9); index += len-9; } printlast(input+index,9); printf("\n"); } return 0; }
int main () { int i; mpz_t n, tot; mpz_init(n); mpz_init(tot); mpz_set_ui(tot, 0); for (i=1; i<=1000; i++ ){ mpz_set_ui(n, i); mpz_pow_ui(n,n,i); mpz_add(tot, tot, n); } printf("Solution is " ); printlast (10, tot); }
bool read_next_frame(const gmx_output_env_t *oenv, t_trxstatus *status, t_trxframe *fr) { real pt; int ct; gmx_bool bOK, bMissingData = FALSE, bSkip = FALSE; bool bRet = false; int ftp; pt = status->tf; do { clear_trxframe(fr, FALSE); if (status->tng) { /* Special treatment for TNG files */ ftp = efTNG; } else { ftp = gmx_fio_getftp(status->fio); } switch (ftp) { case efTRR: bRet = gmx_next_frame(status, fr); break; case efCPT: /* Checkpoint files can not contain mulitple frames */ break; case efG96: { t_symtab *symtab = nullptr; read_g96_conf(gmx_fio_getfp(status->fio), nullptr, nullptr, fr, symtab, status->persistent_line); bRet = (fr->natoms > 0); break; } case efXTC: if (bTimeSet(TBEGIN) && (status->tf < rTimeValue(TBEGIN))) { if (xtc_seek_time(status->fio, rTimeValue(TBEGIN), fr->natoms, TRUE)) { gmx_fatal(FARGS, "Specified frame (time %f) doesn't exist or file corrupt/inconsistent.", rTimeValue(TBEGIN)); } initcount(status); } bRet = read_next_xtc(status->fio, fr->natoms, &fr->step, &fr->time, fr->box, fr->x, &fr->prec, &bOK); fr->bPrec = (bRet && fr->prec > 0); fr->bStep = bRet; fr->bTime = bRet; fr->bX = bRet; fr->bBox = bRet; if (!bOK) { /* Actually the header could also be not ok, but from bOK from read_next_xtc this can't be distinguished */ fr->not_ok = DATA_NOT_OK; } break; case efTNG: bRet = gmx_read_next_tng_frame(status->tng, fr, nullptr, 0); break; case efPDB: bRet = pdb_next_x(status, gmx_fio_getfp(status->fio), fr); break; case efGRO: bRet = gro_next_x_or_v(gmx_fio_getfp(status->fio), fr); break; default: #if GMX_USE_PLUGINS bRet = read_next_vmd_frame(status->vmdplugin, fr); #else gmx_fatal(FARGS, "DEATH HORROR in read_next_frame ftp=%s,status=%s", ftp2ext(gmx_fio_getftp(status->fio)), gmx_fio_getname(status->fio)); #endif } status->tf = fr->time; if (bRet) { bMissingData = (((status->flags & TRX_NEED_X) && !fr->bX) || ((status->flags & TRX_NEED_V) && !fr->bV) || ((status->flags & TRX_NEED_F) && !fr->bF)); bSkip = FALSE; if (!bMissingData) { ct = check_times2(fr->time, status->t0, fr->bDouble); if (ct == 0 || ((status->flags & TRX_DONT_SKIP) && ct < 0)) { printcount(status, oenv, fr->time, FALSE); } else if (ct > 0) { bRet = false; } else { printcount(status, oenv, fr->time, TRUE); bSkip = TRUE; } } } } while (bRet && (bMissingData || bSkip)); if (!bRet) { printlast(status, oenv, pt); if (fr->not_ok) { printincomp(status, fr); } } return bRet; }
gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxframe *fr) { real pt; int ct; gmx_bool bOK, bRet, bMissingData = FALSE, bSkip = FALSE; int dummy = 0; int ftp; bRet = FALSE; pt = fr->tf; do { clear_trxframe(fr, FALSE); fr->tppf = fr->tpf; fr->tpf = fr->tf; if (status->tng) { /* Special treatment for TNG files */ ftp = efTNG; } else { ftp = gmx_fio_getftp(status->fio); } switch (ftp) { case efTRR: bRet = gmx_next_frame(status, fr); break; case efCPT: /* Checkpoint files can not contain mulitple frames */ break; case efG96: read_g96_conf(gmx_fio_getfp(status->fio), NULL, fr, status->persistent_line); bRet = (fr->natoms > 0); break; case efXTC: /* B. Hess 2005-4-20 * Sometimes is off by one frame * and sometimes reports frame not present/file not seekable */ /* DvdS 2005-05-31: this has been fixed along with the increased * accuracy of the control over -b and -e options. */ if (bTimeSet(TBEGIN) && (fr->tf < rTimeValue(TBEGIN))) { if (xtc_seek_time(status->fio, rTimeValue(TBEGIN), fr->natoms, TRUE)) { gmx_fatal(FARGS, "Specified frame (time %f) doesn't exist or file corrupt/inconsistent.", rTimeValue(TBEGIN)); } initcount(status); } bRet = read_next_xtc(status->fio, fr->natoms, &fr->step, &fr->time, fr->box, fr->x, &fr->prec, &bOK); fr->bPrec = (bRet && fr->prec > 0); fr->bStep = bRet; fr->bTime = bRet; fr->bX = bRet; fr->bBox = bRet; if (!bOK) { /* Actually the header could also be not ok, but from bOK from read_next_xtc this can't be distinguished */ fr->not_ok = DATA_NOT_OK; } break; case efTNG: bRet = gmx_read_next_tng_frame(status->tng, fr, NULL, 0); break; case efPDB: bRet = pdb_next_x(status, gmx_fio_getfp(status->fio), fr); break; case efGRO: bRet = gro_next_x_or_v(gmx_fio_getfp(status->fio), fr); break; default: #ifdef GMX_USE_PLUGINS bRet = read_next_vmd_frame(fr); #else gmx_fatal(FARGS, "DEATH HORROR in read_next_frame ftp=%s,status=%s", ftp2ext(gmx_fio_getftp(status->fio)), gmx_fio_getname(status->fio)); #endif } fr->tf = fr->time; if (bRet) { bMissingData = (((fr->flags & TRX_NEED_X) && !fr->bX) || ((fr->flags & TRX_NEED_V) && !fr->bV) || ((fr->flags & TRX_NEED_F) && !fr->bF)); bSkip = FALSE; if (!bMissingData) { ct = check_times2(fr->time, fr->t0, fr->bDouble); if (ct == 0 || ((fr->flags & TRX_DONT_SKIP) && ct < 0)) { printcount(status, oenv, fr->time, FALSE); } else if (ct > 0) { bRet = FALSE; } else { printcount(status, oenv, fr->time, TRUE); bSkip = TRUE; } } } } while (bRet && (bMissingData || bSkip)); if (!bRet) { printlast(status, oenv, pt); if (fr->not_ok) { printincomp(status, fr); } } return bRet; }
int main(){ printmenu(); int type; double op2; char s[MAXOP]; while ((type = getop(s)) != END) { switch (type) { case NUMBER: push(atof(s)); break; case '+': if (sp > 1){ push(pop() + pop()); } else printf("Cannot add. Not enough elemnts in stack ;n; \n"); break; case '*': if (sp > 1){ push(pop() * pop()); } else printf("Cannot multiply. Not enough elements in stack ;n; \n"); break; case '-': if (sp > 1){ op2 = pop(); push(pop() - op2); } else printf("Cannot subtract. Not enough elements in stack ;n; \n"); break; case '/': if (sp > 1){ op2 = pop(); if (op2 != 0.0) push(pop() / op2); else printf("error: zero divisor ;n;\n"); } else printf("Cannot divide. Not enough elements in stack ;n; \n"); break; case '%': if (sp > 1){ op2 = pop(); if (op2 != 0.0) push((int)(pop()) % (int)(op2)); else printf("error:remainder by zero is undefined ;n;\n"); } else printf("Cannot get remainder. Not enough elements in stack ;n;\n"); break; case 'p': print(); break; case 'd': duplicate(); break; case 's': swap(); break; case 'c': printf("clearing stack \n"); clear(); break; case '\n': printlast(); break; case 'm': printmenu(); break; default: printf("error: unknown command ;n; %s\n", s); break; } } return 0; }