//--------------------------------------------------------------------- // 検索と置き換えの実行 int __fastcall TValRepDlg::Execute(double &nd, double &od) { double od1, od2; double nd1, nd2; int f = FALSE; RepSel->Enabled = FALSE; InvSel->Enabled = FALSE; EditOld->Text = StrDbl(od); EditNew->Text = StrDbl(od); Calc(od1, AnsiString(EditOld->Text).c_str()); Calc(nd1, AnsiString(EditNew->Text).c_str()); if( ShowModal() == IDOK ){ Calc(od2, AnsiString(EditOld->Text).c_str()); Calc(nd2, AnsiString(EditNew->Text).c_str()); if( od1 != od2 ){ od = od2; } if( nd1 != nd2 ){ nd = nd2; } if( od != nd ) f = TRUE; } return f; }
void MainWindow::operations(int i) { switch (i) { case '+': case '*': case '/': case '-': arg = Calc(arg, ui->lineEdit->text().toInt(), operation); ui->lineEdit->setText(QString::number(arg)); valueChanged = true; operation = i; break; case 'C': ui->lineEdit->setText("0"); arg = 0; operation = '+'; valueChanged = false; break; case '=': arg = Calc(arg, ui->lineEdit->text().toInt(), operation); ui->lineEdit->setText(QString::number(arg)); valueChanged = true; arg = 0; operation = '+'; break; } }
void Trig_eff(){ Char_t *Hijing_file = "/store/user/tuos/pPb_MC_MinBiasTree_v4_Hijing_180k.root"; Char_t *Hijing_outfile1 = "pPbHist_Hijing_Es.root"; Char_t *Hijing_outfile2 = "pPbHist_Hijing_Tr.root"; Char_t *Hijing_outfile3 = "pPbHist_Hijing_TrandEs.root"; Char_t *Epos_file = "/store/user/tuos/pPb_MC_MinBiasTree_v4_Epos_189k.root"; Char_t *Epos_outfile1 = "pPbHist_Epos_Es.root"; Char_t *Epos_outfile2 = "pPbHist_Epos_Tr.root"; Char_t *Epos_outfile3 = "pPbHist_Epos_TrandEs.root"; Char_t *condition1 = "ES"; Char_t *condition2 = "TR"; Char_t *condition3 = "TRandES"; ofstream fouttxt; Char_t *outtxt="Eff_Result.txt"; fouttxt.open(outtxt); //Calc(Hijing_file,Hijing_outfile1,condition1,fouttxt); //Calc(Epos_file,Epos_outfile1,condition1,fouttxt); //Calc(Hijing_file,Hijing_outfile2,condition2,fouttxt); //Calc(Epos_file,Epos_outfile2,condition2,fouttxt); Calc(Hijing_file,Hijing_outfile3,condition3,fouttxt); Calc(Epos_file,Epos_outfile3,condition3,fouttxt); fouttxt.close(); }
void GO(int x,int fx){ int px=b[COT2::a[x]];BIT::I(px,-1);BIT::I(b[COT2::a[x]]=D[x]=fx==-1?1:D[fx]+1,1); for(QUE*p=Q[x];p;p=p->next)if(!p->ans){ int fu=fa(p->u);if(!D[fu])continue; p->ans=BIT::S(D[fu])+Calc(p->u,fu,x)+Calc(p->v,fu,x); Clean(p->u);Clean(p->v); }for(EDGE*p=COT2::map[x];p;p=p->next)if(!d[p->y]&&p->y!=fx)CT::T[p->y]=CT::I(CT::T[x],0,n,COT2::a[p->y]),GO(p->y,x); BIT::I(b[COT2::a[x]]=px,1);BIT::I(D[x],-1);D[x]=0; }inline bool Run(){
//--------------------------------------------------------------------------- void __fastcall TMediaDlgBox::GridSetEditText(TObject *Sender, int ACol, int ARow, const UnicodeString Value) { double d; if( Grid->EditorMode == TRUE ) return; if( ARow ){ ARow--; switch(ACol){ case 1: // DIE(導) if( Calc(d, AnsiString(Value).c_str()) == TRUE){ lenv.rel[ARow] = d; GridNewLine(ARow); } break; case 2: // COND(誘電) if( Calc(d, AnsiString(Value).c_str()) == TRUE){ lenv.cond[ARow] = d/1000.0; GridNewLine(ARow); } break; case 3: // XorR(m) if( *Value.c_str() ){ if( Calc(d, AnsiString(Value).c_str()) == TRUE){ lenv.intval[ARow] = d; GridNewLine(ARow); } } else if( ARow >= (lenv.mmax - 1) ){ lenv.intval[ARow] = NULLV; GridNewLine(ARow); } break; case 4: // H(m) if( *Value.c_str() ){ if( Calc(d, AnsiString(Value).c_str()) == TRUE){ lenv.height[ARow] = d; GridNewLine(ARow); } } else if( ARow >= (lenv.mmax - 1) ){ lenv.height[ARow] = NULLV; GridNewLine(ARow); } break; } } }
void GasAccumStrategy::Calc(EndListRef &jun,MOCLumpedInertia &Inertia,double dPolytropic,double dCA,double &dMass,double &dPress,double &dVolume) { double dFun =0; double dGrad = 0; double dNewMass = 0; double dStep = 5; double dSign = 0; Calc(jun,Inertia,dPolytropic,dCA,dMass,dPress,dVolume,dNewMass,dSign,dGrad); while(TRUE) {//查找根区间 dNewMass = dNewMass - dStep*dSign/fabs(dSign); Calc(jun,Inertia,dPolytropic,dCA,dMass,dPress,dVolume,dNewMass,dFun,dGrad); if(dFun/dSign <0) break; } while(TRUE) {//二分法 dStep = dStep / 2; if(dFun > 0) { dNewMass = dNewMass - dStep; } else { dNewMass = dNewMass + dStep; } Calc(jun,Inertia,dPolytropic,dCA,dMass,dPress,dVolume,dNewMass,dFun,dGrad); if(dStep < 0.01||fabs(dFun)<1E-2) { break; } } int n=0; while (n<100) {//牛顿迭代 dNewMass = dNewMass -dFun/dGrad; Calc(jun,Inertia,dPolytropic,dCA,dMass,dPress,dVolume,dNewMass,dFun,dGrad); if(-1E-10<dFun&&dFun<1E-10) break; n++; } jun.BranchStrategy(dNewMass); dVolume += MOCFluid::TranMassToV((dNewMass+dMass)/2); dMass = dNewMass; dPress = dCA/pow(dVolume,dPolytropic); }
bool nsCounterUseNode::InitTextFrame(nsGenConList* aList, nsIFrame* aPseudoFrame, nsIFrame* aTextFrame) { nsCounterNode::InitTextFrame(aList, aPseudoFrame, aTextFrame); nsCounterList *counterList = static_cast<nsCounterList*>(aList); counterList->Insert(this); bool dirty = counterList->IsDirty(); if (!dirty) { if (counterList->IsLast(this)) { Calc(counterList); nsAutoString contentString; GetText(contentString); aTextFrame->GetContent()->SetText(contentString, false); } else { // In all other cases (list already dirty or node not at the end), // just start with an empty string for now and when we recalculate // the list we'll change the value to the right one. counterList->SetDirty(); return true; } } return false; }
int main( ) { int i, fi=0, sr, k=1; while( gets(t) ) { sr=-1; for( i=0; i<strlen(t); i++ ) { if( t[i] == '(' ) fi += LB; else if( t[i] == ')' ) fi += RB; else if( t[i] != ' ' ) { s[++sr] = t[i]; switch( t[i] ) { case '!' : f[sr] = fi + 2; break; case '|' : f[sr] = fi + 0; break; case '&' : f[sr] = fi + 1; break; default : f[sr] = OO; break; } } } if( Calc( 0, sr ) )printf("Expression %d: V\n",k++); else printf("Expression %d: F\n",k++); } return 0; }
void __fastcall TACalInfoBox::AutoJXClick(TObject *Sender) { double R, MRO; if( (Calc(R, AnsiString(EditSWRZ->Text).c_str()) == TRUE) && (R > 0.0) ){ UnicodeString MTZ = R < 50 ? "50" : StrDbl(R*2); //ja7ude 1.0 if( InputQuery("MMANA", "整合目標のZを入力", MTZ) == TRUE ){ if( (Calc(MRO, AnsiString(MTZ).c_str()) == TRUE) && (MRO > R) ){ EditSWRJX->Text = StrDbl(-(sqrt((MRO/R)-1) * R)); } else { EditSWRJX->Text = (MRO == R) ? "0":""; } } } }
int main(void) { int i, peo, time,taxi,CalcAns,all; double dist; //input for (i = 0; i <= 2; i++) { if (i == 0) { peo = (int)input(i); } else if (i == 1) { dist = input(i); } else if (i == 2) { time = (int)input(i); } } //Calc CalcAns = Calc(dist); //time CalcAns = timePlus(CalcAns,time); //Taxi num taxi = first(peo); all = CalcAns*taxi; //output output(all,peo); puts("\n\nSystem all ok"); return 0; }
int main(void) { int t; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&f); int i; double low = 0,high = 0; for(i=0;i<n;i++) { scanf("%lf",pie+i); if(pi*pie[i]*pie[i] > high) high = pi*pie[i]*pie[i]; } for(i=0;i<100;i++) { double mid = (low+high)/2; if(Calc(mid) >= f+1) low = mid; else high = mid; } printf("%.4lf\n",low); } return 0; }
int main() { int cn, cc; scanf("%d", &cn); for (cc=1; cc<=cn; cc++) { BI a, b; fprintf(stderr, "Processing Case #%d\n", cc); Get(&a); Get(&b); /* memset(&a, 0, sizeof(a)); memset(&b, 0, sizeof(b)); a.n[0] = 1; b.n[SIZE-1] = 1; */ a = Sqrtsf(a, SEL); b = Sqrtsf(b, FLR); printf("Case #%d: %d\n", cc, Calc(a, b)); } return 0; }
void FormAccount_UpdateRemain(FormAccount* fa) { GtkTreeModel* model; gdouble MoneyNow; gdouble MoneyTotal; gdouble MoneyRemain; const gchar* Str; gchar* StrEnd; gchar Buf[100]; model = gtk_tree_view_get_model(GTK_TREE_VIEW(fa->ListViewAccount)); Str = gtk_entry_get_text(GTK_ENTRY(fa->EntryMoneyNow)); MoneyNow = g_strtod(Str, &StrEnd); if (Calc(Str, &MoneyNow) == -1) { g_snprintf(Buf, sizeof(Buf), "<span foreground=\"#FF0000\">inv!</span>"); } else { FormAccount_SumMoneyTotal(fa, model, &MoneyTotal); MoneyRemain = MoneyNow - MoneyTotal; g_snprintf(Buf, sizeof(Buf), "<span foreground=\"%s\">%.2f</span>", MoneyRemain >= 0 ? "#00FF00" : "#FF0000", MoneyRemain); } gtk_label_set_markup(GTK_LABEL(fa->LabelRemain), Buf); }
void SnowView::MessageReceived(BMessage *msg) { BAlert *info; //msg->PrintToStream(); switch (msg->what) { case MSG_PULSE_ME: if (Parent()) { Calc(); InvalFlakes(); } break; case B_ABOUT_REQUESTED: info = new BAlert("BSnow info", "BSnow, just in case you don't have real one...\n" "" B_UTF8_COPYRIGHT " 2003, François Revol.", "Where is Santa ??"); info->SetFeel(B_NORMAL_WINDOW_FEEL); info->SetLook(B_FLOATING_WINDOW_LOOK); info->SetFlags(info->Flags()|B_NOT_ZOOMABLE); info->Go(NULL); break; default: //#ifdef FORWARD_TO_PARENT /* if (fAttached && Parent()) Parent()->MessageReceived(msg); else */ //#endif BView::MessageReceived(msg); } }
void CCompressionOptionsPage::OnGetTime() { if (!Enc_Info.b_selectrange) { UpdateData(TRUE); Enc_Info.b_gettimefromvob = m_bGetTime; if (m_bGetTime) { m_lFrames = Enc_Info.l_frames; m_lSeconds = (long) (m_lFrames / Enc_Info.f_framerate); } m_hour = m_lSeconds / 3600; m_min = (-m_hour * 3600 + m_lSeconds) / 60; m_sec = (-m_hour * 3600 - m_min * 60 + m_lSeconds); RefreshWindow(); if (Enc_Info.b_enter_filesize == 1) { Calc(); } else { CalcFileSize(); } } }
int _tmain(int argc, _TCHAR* argv[]) { int c = 0; c = Calc(1, CFunc1(), CFunc2(), 2); int e = Calc(1, CFunc1(), CFunc3(), 3); int f = Calc(1, CFunc2(), CFunc3(), 4); printf("c = %d, e=%d, f=%d\n", c,e,f); int d = 0; scanf("%d", &d); return 0; }
//--------------------------------------------------------------------------- int main(int argc, char *argv[]) { // The next line is just for shutting up the compiler warning // about unused variables without getting another warning about not // beeing able to use type lists in function declarations. printf("Executing \"%s\" (argc=%d)\n", argv[0], argc); Calc(); printf("done..."); }
void Parser::Parse() { t = NULL; la = dummyToken = new Token(); la->val = coco_string_create(L"Dummy Token"); Get(); Calc(); Expect(0); Expect(0); }
static void button_3(GtkWidget *win, GtkWidget *main_calc_box, GtkWidget *button) { button = gtk_button_new_with_label("Enter"); gtk_widget_set_hexpand(GTK_WIDGET(button), TRUE); gtk_widget_set_vexpand(GTK_WIDGET(button), TRUE); gtk_container_set_border_width(GTK_CONTAINER(button), 3); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(Calc().notDone), (gpointer) win); gtk_grid_attach(GTK_GRID(main_calc_box), button, 4, 4, 2, 1); }
double BreckerStrategy::SubsonicOutPress(EndListRef &jun,GasProperty &gas,double dCdA) { double dFun =0; double dGrad = 0; double dPr=1; double dStep = 0.1; BOOL bFlag = TRUE; while(TRUE) { Calc(jun,gas,dCdA,dPr,FALSE,dFun,dGrad); if(dStep < 0.00001||fabs(dFun)<1E-2) { break; } if(dFun > 0) { if(!bFlag) { dStep = dStep / 2; bFlag = TRUE; } dPr = dPr - dStep; } else { if(bFlag) { dStep = dStep / 2; bFlag = FALSE; } dPr = dPr + dStep; } } int n=0; while (n<100) { dPr = dPr -dFun/dGrad; Calc(jun,gas,dCdA,dPr,FALSE,dFun,dGrad); if(-1E-8<dFun&&dFun<1E-8) break; n++; } return dPr*gas.GasPress(); }
int main() { Calc(); while (true) { int N, K; scanf("%d%d", &N, &K); if (!N && !K) break; printf("%d\n", C[N][K]); } return 0; }
int ProcMath(char *s) //функция изменяет строку! { if (!s) { fprintf(stderr, "string is null"); return 0; } int i = 0; //итератор int a = 0; //действие(+-*/?) int b = 0; //1й операнд int c = 0; //2й операнд while (s[i] == ' ' || s[i] == '\t') { if (!s[i]) return 0; i++; } //пропускаем все пробелы if (s[i++] != '[') return 0; //проверяем первый символ while (s[i] == ' ' || s[i] == '\t') { if (!s[i]) return 0; i++; } //пропускаем все пробелы a = s[i++]; if (a != '+' && a != '-' && a != '*' && a != '/' && a != '?') return 0; //проверяем знак while (s[i] == ' ' || s[i] == '\t') { if (!s[i]) return 0; i++; } //пропускаем все пробелы if (sscanf(s+i, "%d%d", &b, &c) != 2) return 0; //читаем числа while (s[i] != ']') { if (!s[i]) return 0; i++; } //находим конец операции if (i>=strlen(s)) return 0; //проверка на наличие конца операции char *buf = Calc(a,b,c); //выполняем операцию if (!buf) return 0; //printf("buf: %s\ns: %s\n", buf, s); //изменяем строку char tmp1[1024]; sprintf(tmp1, "%s%s", buf, s + ++i); s = strcpy(s, tmp1); /* int j = 0; for (j = 0; j < strlen(buf); j++) s[j] = buf[j]; //копируем результат free(buf); for (; s[i-1]; i++, j++) { s[j] = s[i]; } */ return 1; }
void nsQuoteList::RecalcAll() { for (nsQuoteNode* node = FirstNode(); node; node = Next(node)) { int32_t oldDepth = node->mDepthBefore; Calc(node); if (node->mDepthBefore != oldDepth && node->mText && node->IsRealQuote()) node->mText->SetData(*node->Text()); } }
void FlowJunStrategy::Calc(EndListRef &jun,double dMass) { EndInfo *pEnd = NULL; IteratorPtr<EndInfo> ItPtr(jun.CreatEndIt()); for(ItPtr->Fist();!ItPtr->IsDone();ItPtr->Next()) { pEnd = &ItPtr->CurrentItem(); ASSERT(pEnd != NULL); Calc(jun,*pEnd,dMass); } }
Sound::Sound::Sound (std::string Filename) : fn(Filename), Volume (127), X (0), Y (0), midi(0) { if(EnableSound) { if (LoCase (Filename.substr (Filename.length () - 4)) == ".mid") midi = load_midi (Filename.c_str()); else sndLoadSound (fn); } Calc(); }
void Sound::Sound::play (int loopmode) { if(!EnableSound) return; Calc (); if (midi) play_midi (midi, loopmode != 0); else sndPlaySound (fn, _volume, _balance); SetSpeaker (); }
void Trig_eff_DS() { //Char_t *Epos_file = "root://eoscms//eos/cms/store/group/phys_heavyions/azsigmon/HiForest_pPb_Epos_336800.root"; //Char_t *Epos_file = "/afs/cern.ch/work/k/kjung/public/EposForest_CandyCane_Merged1.root"; TString Epos_file = "/store/user/tuos/pPb_MC_MinBiasTree_v4_Epos_189k.root"; //Char_t *Hijing_file="root://eoscms//eos/cms/store/group/phys_heavyions/dgulhan/pPb_Hijing_MB02/prod12/HiForest_v68_merged01/H02_merged_hiforest_v68_prod12.root"; //Char_t *Hijing_file="root://eoscms//eos/cms/store/caf/user/dgulhan/pPb_Hijing_MB01/prod12/HiForest_v68_merged02/H01_merged_hiforest_v68_prod12.root"; //Char_t *Hijing_file="root://eoscms//eos/cms/store/caf/user/dgulhan/pPb_Hijing_MB01/prod09/HiForest_v55_merged02/merged_forest_0.root"; TString Hijing_file="/store/user/tuos/pPb_MC_MinBiasTree_v4_Hijing_180k.root"; TString dir="output/noweight"; TString Epos_outfile = Form("%s/pPbHist_Epos_DS.root",dir.Data()); TString Hijing_outfile = Form("%s/pPbHist_Hijing_DS.root",dir.Data()); Calc(Epos_file,Epos_outfile); Calc(Hijing_file,Hijing_outfile); }
//--------------------------------------------------------------------------- void __fastcall TWireEditDlg::EditVDegChange(TObject *Sender) { if( !EnbCalc ) return; double d; if( Calc(d, AnsiString(EditVDeg->Text).c_str()) == TRUE ){ if( d != YZD ){ YZD = d; CalcXYZ(); DispItem(12); } } }
//--------------------------------------------------------------------------- void __fastcall TWireEditDlg::EditRChange(TObject *Sender) { if( !EnbCalc ) return; double d; if( Calc(d, AnsiString(EditR->Text).c_str()) == TRUE ){ d = SetRmdVal(d) / 1000.0; if( d != NewW.R ){ NewW.R = d; DispItem(6); } } }
void CCompressionOptionsPage::OnChangeEditSec() { Seconds2Frames(); if (m_intEnterFileSize == 0) { CalcFileSize(); } else { Calc(); } }