calc::calc(QWidget *parent) : QMainWindow(parent) { setupUi(this); setFixedSize(sizeHint()); clearall(); connect (Button1,SIGNAL(clicked()),this,SLOT(add1())); connect (Button2,SIGNAL(clicked()),this,SLOT(add2())); connect (Button3,SIGNAL(clicked()),this,SLOT(add3())); connect (Button4,SIGNAL(clicked()),this,SLOT(add4())); connect (Button5,SIGNAL(clicked()),this,SLOT(add5())); connect (Button6,SIGNAL(clicked()),this,SLOT(add6())); connect (Button7,SIGNAL(clicked()),this,SLOT(add7())); connect (Button8,SIGNAL(clicked()),this,SLOT(add8())); connect (Button9,SIGNAL(clicked()),this,SLOT(add9())); connect (Button0,SIGNAL(clicked()),this,SLOT(add0())); connect (backButton,SIGNAL(clicked()),this,SLOT(delnum())); connect (pointButton,SIGNAL(clicked()),this,SLOT(insertpoint())); connect (plusButton,SIGNAL(clicked()),this,SLOT(plus())); connect (minusButton,SIGNAL(clicked()),this,SLOT(minus())); connect (multiplyButton,SIGNAL(clicked()),this,SLOT(multiply())); connect (divideButton,SIGNAL(clicked()),this,SLOT(divide())); connect (equalButton,SIGNAL(clicked()),this,SLOT(equal())); connect (CButton,SIGNAL(clicked()),this,SLOT(clearall())); connect (actionAbout_Qt,SIGNAL(triggered()),this,SLOT(about())); connect (actionExit,SIGNAL(triggered()),this,SLOT(close())); connect (pmButton,SIGNAL(clicked()),this,SLOT(togglepm())); }
int main() { gets(s); while (1 == 1) { clearall(); len = strlen(s); if ((len == 3) && (s[0] == 'E') && (s[1] == 'N') && (s[2] == 'D')) break; for (i = 0;i < len;i++) alpha[s[i]]++; tot = 0; for (i = 1;i <= 500;i++) if (alpha[i] != 0) { tot++; ch[tot] = i; va[tot] = alpha[i]; } for (i = 1;i <= tot;i++) for (j = i;j <= tot;j++) if (va[i] > va[j]) { temp = va[i]; va[i] = va[j]; va[j] = temp; temp = ch[i]; ch[i] = ch[j]; ch[j] = temp; } construct(); gets(s); } return 0; }
void newfile() { sys.cell.row = 8; sys.cell.col = MONTH; sys.decimal = 2; sys.screen = SCREEN1; sys.display = HELDS; clearall(); }
bool route(int ch) { if (ch == 'q') { freebrd(); endwin(); return false; } if (game.ended) { if (ch != ERR) newgame(); return true; } if (ch == 'p') { game.paused = (game.paused ? false : true); if (game.paused) drawpause(); else clearall(); } if (ch == '?') { game.paused = (game.paused ? false : true); if (game.paused) drawctrls(); else clearall(); } if (!game.paused) { switch (ch) { case 'k': case KEY_UP: rotpc(); break; case 'j': case KEY_DOWN: mvpcdown(); break; case 'h': case KEY_LEFT: mvpcleft(); break; case 'l': case KEY_RIGHT: mvpcright(); break; case ' ': drppc(); break; default: break; } } return true; }
int main() { gets(s); while (1 == 1) { clearall(); len = strlen(s); if ((len == 3) && (s[0] == 'E') && (s[1] == 'N') && (s[2] == 'D')) break; for (i = 0;i < len;i++) alpha[s[i]]++; tot = 0; for (i = 1;i <= 500;i++) if (alpha[i] != 0) { tot++; ch[tot] = i; va[tot] = alpha[i]; } for (i = 1;i <= tot;i++) for (j = i;j <= tot;j++) if (va[i] > va[j]) { temp = va[i]; va[i] = va[j]; va[j] = temp; temp = ch[i]; ch[i] = ch[j]; ch[j] = temp; } construct(); result = 0; for (i = 1;i <= tot;i++) { temp = i; j = 0; while (tree[temp].father != temp) { temp = tree[temp].father; j++; } result += j*va[i]; } if (result == 0) result = len*1; bit = 8*len; ratio = ((double)bit/(double)result); printf("%d %d %.1f\n",bit,result,ratio); gets(s); } return 0; }
void calc::delnum() { if (!added) { first = true; } int lastpoint = shownumber.length() - 1; if (lastpoint<0) { clearall(); return; } if (shownumber[lastpoint]=='.') {point = '.';} shownumber.remove(lastpoint,1); if (shownumber.length() == 0) { shownumber = "0"; point = '.'; } refresh(); }
void docommand(char ch) { int count; char dateb[7]; switch (ch) { case ARROWR : if (status.stockprice != 3 + 1) exit(0);goright(); break; case ARROWL : if (status.stockprice != 5 - 1) exit(0);goleft(); break; case ARROWU : if (status.stockprice != 2 + 2) exit(0);goup(); break; case ARROWD : if (status.stockprice != 3 + 1) exit(0);godown(); break; case HOME : leavecell(sys.cell); if ((sys.screen == SCREEN1 || sys.screen == SCREEN3) && page == PAGEDOWN) { sys.cell.row = 23; sys.cell.col = MONTH; } else if (sys.screen == SCREEN2) { sys.cell.row = 8; sys.cell.col = SHARESPER; } else { sys.cell.row = 8; sys.cell.col = MONTH; } entercell(sys.cell); break; case END : leavecell(sys.cell); if ((sys.screen == SCREEN1 || sys.screen == SCREEN3) && page == PAGEDOWN) { sys.cell.row = 37; sys.cell.col = MONTH; } else if (sys.screen == SCREEN2) { sys.cell.row = 22; sys.cell.col = SHARESPER; } else { sys.cell.row = 22; sys.cell.col = MONTH; } entercell(sys.cell); break; case PGUP : if ((sys.screen == SCREEN1 || sys.screen == SCREEN3) && page == PAGEDOWN) { page = PAGEUP; if (sys.cell.row >= 8) sys.cell.row -= 15; disppage(); } showall(); entercell(sys.cell); break; case PGDN : if ((sys.screen == SCREEN1 || sys.screen == SCREEN3) && page == PAGEUP) { page = PAGEDOWN; if (sys.cell.row >= 8) sys.cell.row += 15; disppage(); } showall(); entercell(sys.cell); break; case F01 : help();break; case F02 : demo(); break; case F03 : demo(); break; case F04 : sortstatus(); genscreen(); entercell(sys.cell); break; case F05 : { if (drawgraph(choice(6,graphchoice)) < 0) errormessage("Graphics initialisation error"); genscreen(); showtotals(); entercell(sys.cell); } break; case F06 : leavecell(sys.cell); switch (choice(3,screenchoice)) { case 1 : if (tosavesys) savesys(); sys.screen = SCREEN1; page = PAGEUP; sys.cell.col = MONTH; sys.cell.row = 8; sys.display = HELDS; genscreen(); break; case 2 : sys.screen = SCREEN2; sys.display = HELDS; page = PAGEUP; sys.cell.row = 8; sys.cell.col = EXPIRYDAY; genscreen(); break; case 3 : if (tosavesys) savesys(); sys.cell.col = MONTH; page = PAGEUP; sys.screen = SCREEN3; sys.display = INVVOL; sys.cell.row = 8; wait(); if (recalcvolvalues) calcallvol(); ready(); genscreen(); break; } showtotals(); entercell(sys.cell); break; case F07 : switch(choice(3,clearchoice)) { case 1 : if (sys.cell.row < 8 || sys.screen == SCREEN2) break; wait(); clearrow(); calcall(); showall(); totals(); entercell(sys.cell); break; case 2 : wait(); switch( sys.cell.col) { case VOLC : case VALUEC : case VOLP : case DELTAC : case VALUEP : case DELTAP: case SHAREPRICE :break; case STOCKHELD : status.stockheld = 0; break; case VOLATILITY : status.volatility = 0.0;break; case INTEREST : status.interest = 0.0; break; case DATE : case YEARMONTH : case SHARESPER : for (count =0;count <24; count++) status.sizepay[count].sharesper = 1000; break; case EXPIRYDAY : case DAYSLEFT : case MONTH : break; case STRIKE : for (count = 0;count < 30; count++) { status.data[count].strike = 0.0; status.data[count].volc = 0.0; status.data[count].volp = 0.0; } break; case MARKETC : for (count = 0;count < 30; count++) { status.data[count].marketc = 0.0; status.data[count].volc = 0.0; } break; case HELDC : for (count = 0;count < 30; count++) status.data[count].heldc = 0; break; case MARKETP : for (count = 0;count < 30; count++) { status.data[count].marketp = 0.0; status.data[count].volp = 0.0; } break; case HELDP : for (count = 0;count < 30; count++) status.data[count].heldp = 0; break; case DIVIDENDDAY : for (count = 0;count < 24; count++) status.sizepay[count].dday = 0; break; case DIVIDENDCENTS : for (count = 0;count < 24; count++) status.sizepay[count].payout = 0; break; } wait(); calcall(); showall(); totals(); break; case 3: clearall();wait(); wait(); calcall(); showall(); totals();break; /* clear all set shares per con */ } showtotals(); ready(); entercell(sys.cell); /* inverse vol now invalid */ break; case F08 : leavecell(sys.cell); switch( choice(7, utilchoice)) { case 1 : getdir(); break; case 2 : bonusissue(); wait(); calcall(); showall(); totals(); showtotals(); ready(); break; case 3 : cashissue(); wait(); calcall(); showall(); totals(); showtotals(); ready(); break; case 4: switch( choice(3,resolutionchoice)) { case 1: numpts = 10; break; case 2: numpts = 15; break; case 3: numpts = 30; break; } break; case 5:switch (choice(3,printchoice)) { case 1: printdetails(); break; case 2: demo1();break; case 3: demo1(); break; } break; case 6: filedelete(); break; case 7 : reinstall(); } entercell(sys.cell); break; case F09 : switch (sys.screen) { case SCREEN1 : leavecell(sys.cell); if (sys.display == HELDS) sys.display = DELTAS; else sys.display = HELDS; if (sys.cell.row >= 8) sys.cell.col = MONTH; textcolor(sys.graphics.colors.heading); textbackground(sys.graphics.colors.databack); drawheadings(); showall(); showtotals(); entercell(sys.cell);break; case SCREEN2 : break; case SCREEN3 : leavecell(sys.cell); if (sys.display == INVVOL) sys.display = OVERVALUED; else sys.display = INVVOL; textcolor(sys.graphics.colors.heading); textbackground(sys.graphics.colors.databack); drawheadings(); showall(); showtotals(); entercell(sys.cell);break; } break; case F10 : switch (choice(3,quitchoice)) { case 0 : break; case 1 : wait(); textcolor(LIGHTGRAY); textbackground(BLACK); savesys(); clrscr(); gotoxy(2,2); cprintf(" The Option Analyst is a product of"); gotoxy(2,3); cprintf(" EFAM RESOURCES Pty. Ltd.\n"); retcursor(); exit(0); break; case 2 : demo(); break; case 3 : break; } break; } }
int bf_run(char *buff,int size) { char *code=buff; int idx=0,tmp; int nbrace=0; /*counts the no. of loops encountered inside an unexcuted loop*/ first=current=new_cell(); while(idx<size){ if(nbrace){ if(code[idx]=='[')++nbrace; else if(code[idx]==']')--nbrace; } else{ switch(code[idx]){ case '+': current->value++; break; case '-': current->value--; break; case '>': if(current->next==NULL){ current->next=new_cell(); (current->next)->prev=current; } current=current->next; break; case '<': if(current->prev==NULL){ first=current->prev=new_cell(); (current->prev)->next=current; } current=current->prev; break; case '.': putchar(current->value); break; case ',': current->value=getchar(); break; case '[': //push(idx+1); if(current->value==0) ++nbrace; else push(idx+1); break; case ']': tmp=pop(); if(tmp!=-1){ if(current->value!=0){ push(tmp); idx=tmp-1; /*remember ++idx at the end of the loop?*/ break; } } break; } } ++idx; } clearall(first); }