这篇教程C++ Divide函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Divide函数的典型用法代码示例。如果您正苦于以下问题:C++ Divide函数的具体用法?C++ Divide怎么用?C++ Divide使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Divide函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main(){ try { std::cout << Divide(5, 2) << std::endl; std::cout << Divide(10, 0) << std::endl; std::cout << Divide(3, 3) << std::endl; } catch (const std::invalid_argument& e) { std::cout << "Caught exception: " << e.what() << std::endl; } return 0;}
开发者ID:MidoriYakumo,项目名称:ModernCpp,代码行数:15,
示例2: VirtualSpace_Releasevoid VirtualSpace_Release(uint32_t* logAddrToRealease, uint32_t nbPages){ FreeSpace* nextFS = VirtualSpace_GetNextFreeSpace(logAddrToRealease); FreeSpace* prevFS = VirtualSpace_GetPrevious(nextFS); uint8_t createNewFS = 1; if((*nextFS).addrSpace==logAddrToRealease+nbPages*PAGE_SIZE) { (*nextFS).addrSpace = logAddrToRealease; (*nextFS).nbPagesFree += nbPages; createNewFS = 0; } if((*prevFS).addrSpace+(*prevFS).nbPagesFree*PAGE_SIZE==logAddrToRealease) { (*prevFS).nbPagesFree += nbPages; createNewFS = 0; } if(createNewFS) { uint32_t nbMiniFrames; uint32_t mod; Divide( sizeof(FreeSpace), MINI_FRAMES_SIZE_OF_A_FRAME+1, &nbMiniFrames,&mod); FreeSpace* newFS = (FreeSpace*)Mini_Alloc(nbMiniFrames,0); (*newFS).nbPagesFree = nbPages; (*newFS).addrSpace = logAddrToRealease; (*newFS).ptNextFreeSpace = nextFS; (*prevFS).ptNextFreeSpace = newFS; }}
开发者ID:kar1m,项目名称:RaspberryPi,代码行数:35,
示例3: CreateSphere// Creates a sphereMesh* CreateSphere(int subdivisions){ nextIndex = 0; // TODO: calc how many items in the arrays we need vertices = new Vertex[100000]; vertexCurrentIndex = 0; indices = new USHORT[100000]; indexCurrentIndex = 0; AddBaseTriangle(CreateVector(0, 0, 1), CreateVector(1, 0, 0), CreateVector(0, 1, 0)); AddBaseTriangle(CreateVector(1, 0, 0), CreateVector(0, 0, -1), CreateVector(0, 1, 0)); AddBaseTriangle(CreateVector(0, 0, -1), CreateVector(-1, 0, 0), CreateVector(0, 1, 0)); AddBaseTriangle(CreateVector(-1, 0, 0), CreateVector(0, 0, 1), CreateVector(0, 1, 0)); AddBaseTriangle(CreateVector(1, 0, 0), CreateVector(0, 0, 1), CreateVector(0, -1, 0)); AddBaseTriangle(CreateVector(0, 0, -1), CreateVector(1, 0, 0), CreateVector(0, -1, 0)); AddBaseTriangle(CreateVector(-1, 0, 0), CreateVector(0, 0, -1), CreateVector(0, -1, 0)); AddBaseTriangle(CreateVector(0, 0, 1), CreateVector(-1, 0, 0), CreateVector(0, -1, 0)); for (int division = 1; division < subdivisions; division++) Divide(); Mesh* mesh = new Mesh(); mesh->Set(vertices, vertexCurrentIndex, indices, indexCurrentIndex); // Free allocated arrays delete [] vertices; delete [] indices; return mesh;}
开发者ID:AnthonyNystrom,项目名称:NuGenBioChemDX,代码行数:30,
示例4: mainint main(){ int x; int start=0,end=100; int y=(start+end)/2; printf("*****************************************************************/n"); printf("Enter the number corresponding to the desired pay rate or action:/n"); printf("a) add/t/t/ts) subtract/n"); printf("m) multiply/t/td) divide/n"); printf("q) quit/n"); printf("*****************************************************************/n"); x=getchar(); switch(x) { case 'a': Add(); break; case 's': Subtract(); break; case 'm': Mutliply(); break; case 'd': Divide(); break; case 'q': printf("Bye~~~~~~/n"); break; }}
开发者ID:gaowanchen,项目名称:C_primer_plus_exercise,代码行数:31,
示例5: efficiencyBinomialErrorsvoid efficiencyBinomialErrors(){ printf("/n Get the binomial errors for efficiencies/n/n"); auto h_num = new TH1D("h_num", "h_num", nbins, 0, nbins); auto h_den = new TH1D("h_den", "h_den", nbins, 0, nbins); for (int i=0; i<nbins; i++) { h_num->SetBinContent(i+1, n_num[i]); h_den->SetBinContent(i+1, n_den[i]); } auto graph = new TGraphAsymmErrors(); graph->Divide(h_num, h_den, "cl=0.683 b(1,1) mode"); auto canvas = new TCanvas("canvas", "canvas"); graph->SetMarkerStyle(kFullCircle); graph->Draw("apz"); graph->Print();}
开发者ID:piedraj,项目名称:AnalysisCMS,代码行数:25,
示例6: ShortestDistancevoid M2MFstAligner::expectation( ){ /* Here we compute the arc posteriors. This routine is almost fun to implement in the FST paradigm. */ for( unsigned int i=0; i<fsas.size(); i++ ){ //Compute Forward and Backward probabilities ShortestDistance( fsas.at(i), &alpha ); ShortestDistance( fsas.at(i), &beta, true ); //Compute the normalized Gamma probabilities and // update our running tally for( StateIterator<VectorFst<LogArc> > siter(fsas.at(i)); !siter.Done(); siter.Next() ){ LogArc::StateId q = siter.Value(); for( ArcIterator<VectorFst<LogArc> > aiter(fsas.at(i),q); !aiter.Done(); aiter.Next() ){ const LogArc& arc = aiter.Value(); const LogWeight& gamma = Divide(Times(Times(alpha[q], arc.weight), beta[arc.nextstate]), beta[0]); //Check for any BadValue results, otherwise add to the tally. //We call this 'prev_alignment_model' which may seem misleading, but // this conventions leads to 'alignment_model' being the final version. if( gamma.Value()==gamma.Value() ){ prev_alignment_model[arc.ilabel] = Plus(prev_alignment_model[arc.ilabel], gamma); total = Plus(total, gamma); } } } alpha.clear(); beta.clear(); }}
开发者ID:Joda89,项目名称:g2p,代码行数:30,
示例7: absfloatM2MFstAligner::maximization(bool lastiter){ //Maximization. Simple count normalization. Probably get an improvement // by using a more sophisticated regularization approach. map<LogArc::Label,LogWeight>::iterator it; float change = abs(total.Value() - prevTotal.Value()); //cout << "Total: " << total << " Change: " << abs(total.Value()-prevTotal.Value()) << endl; prevTotal = total; //Normalize and iterate to the next model. We apply it dynamically // during the expectation step. for (it = prev_alignment_model.begin(); it != prev_alignment_model.end(); it++) { alignment_model[(*it).first] = Divide((*it).second, total); (*it).second = LogWeight::Zero(); } for (int i = 0; i < fsas.size(); i++) { for (StateIterator<VectorFst<LogArc> > siter(fsas[i]); !siter.Done(); siter.Next()) { LogArc::StateId q = siter.Value(); for (MutableArcIterator<VectorFst<LogArc> > aiter(&fsas[i], q); !aiter.Done(); aiter.Next()) { LogArc arc = aiter.Value(); arc.weight = alignment_model[arc.ilabel]; aiter.SetValue(arc); } } } total = LogWeight::Zero(); return change;}
开发者ID:ShahAlay,项目名称:sphinxtrain,代码行数:33,
示例8: solvevoid solve() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%lf%lf", &p[i].x, &p[i].y), p[i].index = i, p[i].in = NULL; Alloc_memory(); sort(p, p + n); for (int i = 0; i < n; i++) Q[i] = p + i; edge *L, *R; Divide(0, n - 1, &L, &R); M = 0; Make_Graph(); Kruskal();}
开发者ID:bywbilly,项目名称:Templates,代码行数:8,
示例9: Factor// Solution taken from: http://mathworld.wolfram.com/QuarticEquation.html// and http://www.csit.fsu.edu/~burkardt/f_src/subpak/subpak.f90int Factor(double a4,double a3,double a2,double a1,double a0,double roots[4][2],const double& EPS){ double R[2],D[2],E[2],R2[2]; if(fabs(a4)<EPS){return Factor(a3,a2,a1,a0,roots,EPS);} a3/=a4; a2/=a4; a1/=a4; a0/=a4; Factor(1.0,-a2,a3*a1-4.0*a0,-a3*a3*a0+4.0*a2*a0-a1*a1,roots,EPS); R2[0]=a3*a3/4.0-a2+roots[0][0]; R2[1]=0; Sqrt(R2,R); if(fabs(R[0])>10e-8){ double temp1[2],temp2[2]; double p1[2],p2[2]; p1[0]=a3*a3*0.75-2.0*a2-R2[0]; p1[1]=0; temp2[0]=((4.0*a3*a2-8.0*a1-a3*a3*a3)/4.0); temp2[1]=0; Divide(temp2,R,p2); Add (p1,p2,temp1); Subtract(p1,p2,temp2); Sqrt(temp1,D); Sqrt(temp2,E); } else{ R[0]=R[1]=0; double temp1[2],temp2[2]; temp1[0]=roots[0][0]*roots[0][0]-4.0*a0; temp1[1]=0; Sqrt(temp1,temp2); temp1[0]=a3*a3*0.75-2.0*a2+2.0*temp2[0]; temp1[1]= 2.0*temp2[1]; Sqrt(temp1,D); temp1[0]=a3*a3*0.75-2.0*a2-2.0*temp2[0]; temp1[1]= -2.0*temp2[1]; Sqrt(temp1,E); } roots[0][0]=-a3/4.0+R[0]/2.0+D[0]/2.0; roots[0][1]= R[1]/2.0+D[1]/2.0; roots[1][0]=-a3/4.0+R[0]/2.0-D[0]/2.0; roots[1][1]= R[1]/2.0-D[1]/2.0; roots[2][0]=-a3/4.0-R[0]/2.0+E[0]/2.0; roots[2][1]= -R[1]/2.0+E[1]/2.0; roots[3][0]=-a3/4.0-R[0]/2.0-E[0]/2.0; roots[3][1]= -R[1]/2.0-E[1]/2.0; return 4;}
开发者ID:Benzlxs,项目名称:PRSM,代码行数:60,
示例10: Termvoid Term() { SignedFactor(); while(Look == '*' || Look == '/') { EmitLn("push rax"); switch(Look) { case '*' : Multiply();break; case '/' : Divide();break; } }}
开发者ID:A-deLuna,项目名称:crenshaw-c-x86_64-compiler,代码行数:10,
示例11: mainint main(){ LinkList l,la,lb,lc; l=CreateList(7); la=CreateList2(0); lb=CreateList2(0); lc=CreateList2(0); Output(l); Divide(l,la,lb,lc); return 0;}
开发者ID:mjyplusone,项目名称:CppPrimer,代码行数:10,
示例12: QuickMediumvoid QuickMedium(T* &vector, int ini, int fin){ if (fin-ini == 1){ if (vector[ini]>vector[fin]) Swap(vector[ini], vector[fin]); } else if (fin-ini > 1){ int division = Divide(vector, ini, fin); SlowMedium(vector, ini, division-1); SlowMedium(vector, division+1, fin); }}
开发者ID:fgallegosalido,项目名称:Algoritmos-Ordenacion,代码行数:10,
示例13: Divide// Divide this surface into two surfaces in// S direction if bS is true, u = (m_fS[0]+m_fS[1])/2// T direction if bS is false, u = (m_fT[0]+m_fT[1])/2bool MH_SrfBezier::DivideHalf(bool bS, MH_SrfBezier& bezier1, MH_SrfBezier& bezier2) const{ float u; if(bS) u = (m_fS[0]+m_fS[1])/2.0f; else u = (m_fT[0]+m_fT[1])/2.0f; return Divide(bS, u, bezier1, bezier2);}
开发者ID:KnowNo,项目名称:backup,代码行数:13,
示例14: MazeMaze :: Maze(){ numRows = 21; numCols = 32; grid = new char*[numRows]; for(int i = 0; i < numRows; i++) grid[i] = new char[numCols]; /* strcpy (grid[0], "###############################"); strcpy (grid[1], "#O# # # # #"); strcpy (grid[2], "# # ### ##### # ##### ### # ###"); strcpy (grid[3], "# # # # # # # # #"); strcpy (grid[4], "# # # # # # ### ### ### # ### #"); strcpy (grid[5], "# # # # # # # # # #"); strcpy (grid[6], "# # # ### ### ####### ##### # #"); strcpy (grid[7], "# # # # # # # # #"); strcpy (grid[8], "########### # # ######### # ###"); strcpy (grid[9], "# # # # # #"); strcpy(grid[10], "# # # ####### # # # # # ##### #"); strcpy(grid[11], "# # # # # # # # # # #"); strcpy(grid[12], "### ### # # ##### ### # #######"); strcpy(grid[13], "# # # # # # # # # #"); strcpy(grid[14], "# # # # # # ############# # # #"); strcpy(grid[15], "# # # # # # # #"); strcpy(grid[16], "# # ##### ##### ####### # #####"); strcpy(grid[17], "# # # # # # # #"); strcpy(grid[18], "# ####### # ### # ### ##### # #"); strcpy(grid[19], "# # # # #X#"); strcpy(grid[20], "###############################"); */ for(int g = 0; g < 21; g++) { grid[g][0] = '#'; grid[g][30] = '#'; } for(int h = 0; h < 31; h++) { grid[0][h] = '#'; grid[20][h] = '#'; } for(int m = 1; m < 20; m++) for(int n = 1; n < 30; n++) grid[m][n] = ' '; srand(time(NULL)); Divide(0, 20, 0, 30); endRow = 19; endCol = 29; currentRow = 1; currentCol = 1; grid[1][1] = 'O'; grid[19][29] = 'X';}
开发者ID:EricRobertBrewer,项目名称:SonomaState,代码行数:55,
示例15: macro6void macro6(){ auto sig_h=new TH1F("sig_h","Signal Histo",50,0,10); auto gaus_h1=new TH1F("gaus_h1","Gauss Histo 1",30,0,10); auto gaus_h2=new TH1F("gaus_h2","Gauss Histo 2",30,0,10); auto bkg_h=new TH1F("exp_h","Exponential Histo",50,0,10); // simulate the measurements TRandom3 rndgen; for (int imeas=0;imeas<4000;imeas++){ bkg_h->Fill(rndgen.Exp(4)); if (imeas%4==0) gaus_h1->Fill(rndgen.Gaus(5,2)); if (imeas%4==0) gaus_h2->Fill(rndgen.Gaus(5,2)); if (imeas%10==0)sig_h->Fill(rndgen.Gaus(5,.5));} // Format Histograms int i=0; for (auto hist : {sig_h,bkg_h,gaus_h1,gaus_h2}) format_h(hist,1+i++); // Sum auto sum_h= new TH1F(*bkg_h); sum_h->Add(sig_h,1.); sum_h->SetTitle("Exponential + Gaussian;X variable;Y variable"); format_h(sum_h,kBlue); auto c_sum= new TCanvas(); sum_h->Draw("hist"); bkg_h->Draw("SameHist"); sig_h->Draw("SameHist"); // Divide auto dividend=new TH1F(*gaus_h1); dividend->Divide(gaus_h2); // Graphical Maquillage dividend->SetTitle(";X axis;Gaus Histo 1 / Gaus Histo 2"); format_h(dividend,kOrange); gaus_h1->SetTitle(";;Gaus Histo 1 and Gaus Histo 2"); gStyle->SetOptStat(0); TCanvas* c_divide= new TCanvas(); c_divide->Divide(1,2,0,0); c_divide->cd(1); c_divide->GetPad(1)->SetRightMargin(.01); gaus_h1->DrawNormalized("Hist"); gaus_h2->DrawNormalized("HistSame"); c_divide->cd(2); dividend->GetYaxis()->SetRangeUser(0,2.49); c_divide->GetPad(2)->SetGridy(); c_divide->GetPad(2)->SetRightMargin(.01); dividend->Draw();}
开发者ID:A2-Collaboration,项目名称:root,代码行数:54,
示例16: Dividevoid Divide(int s, int t, edge **L, edge **R) { edge *a, *b, *c, *ll, *lr, *rl, *rr, *tangent; int n = t - s + 1; if (n == 2) *L = *R = Make_edge(Q[s], Q[t]); else if (n == 3) { a = Make_edge(Q[s], Q[s + 1]), b = Make_edge(Q[s + 1], Q[t]); Splice(a, b, Q[s + 1]); double v = C3(Q[s], Q[s + 1], Q[t]); if (v > eps) c = Join(a, Q[s], b, Q[t], 0), *L = a, *R = b; else if (v < -eps) c = Join(a, Q[s], b, Q[t], 1), *L = c, *R = c; else *L = a, *R = b; } else if (n > 3) { int split = (s + t) / 2; Divide(s, split, &ll, &lr); Divide(split + 1, t, &rl, &rr); Merge(lr, Q[split], rl, Q[split + 1], &tangent); if (Oi(tangent) == Q[s]) ll = tangent; if (Dt(tangent) == Q[t]) rr = tangent; *L = ll; *R = rr; }}
开发者ID:bywbilly,项目名称:Templates,代码行数:20,
示例17: Term1void Term1() { NewLine(); while(Look == '*' || Look == '/') { Push(); switch(Look) { case '*': Multiply(); break; case '/': Divide(); break; } NewLine(); }}
开发者ID:A-deLuna,项目名称:crenshaw-c-x86_64-compiler,代码行数:11,
示例18: LimitedKnapsackint LimitedKnapsack(std::vector<int> c, std::vector<int> w, int B, std::vector<int> n){ std::vector<int> new_c, new_w; for (int i = 0; i < n.size(); ++i) { std::vector<int> d = Divide(n[i]); for(auto l : d){ new_c.push_back(l*c[i]); new_w.push_back(l*w[i]); } } return knapsack(new_c,new_w,B);}
开发者ID:ShiyangHuang,项目名称:AP,代码行数:12,
示例19: vMem_Initvoid vMem_Init(FreeSpace* pt_firstFSDescriptor){ uint32_t nbPagesFree; uint32_t mod; Divide( (HEAP_END-HEAP_BEG), PAGE_SIZE, &nbPagesFree,&mod); (*pt_firstFSDescriptor).nbPagesFree = nbPagesFree; (*pt_firstFSDescriptor).addrSpace = (uint32_t*)HEAP_BEG; (*pt_firstFSDescriptor).ptNextFreeSpace = pt_firstFSDescriptor;}
开发者ID:kar1m,项目名称:RaspberryPi,代码行数:12,
示例20: main//4. (Define) Functionint main (int argc, char *argv[]){ ULong firstNumber; ULong secondNumber; ULong quotient; ULong remainder; Input(&firstNumber, &secondNumber); Divide(firstNumber, secondNumber, "ient, &remainder); Output(quotient, remainder); return 0;}
开发者ID:MJayJang,项目名称:ParkCom,代码行数:13,
示例21: absfloat M2MFstAligner::maximization( bool lastiter ){ //Maximization. Standard approach is simple count normalization. //The 'penalize' option penalizes links by total length. Results seem to be inconclusive. // Probably get an improvement by distinguishing between gaps and insertions, etc. bool cond = false; float change = abs(total.Value()-prevTotal.Value()); if( cond==false ){ map<LogArc::Label,LogWeight>::iterator it; //cout << "Total: " << total << " Change: " << abs(total.Value()-prevTotal.Value()) << endl; prevTotal = total; //Normalize and iterate to the next model. We apply it dynamically // during the expectation step. for( it=prev_alignment_model.begin(); it != prev_alignment_model.end(); it++ ){ alignment_model[(*it).first] = Divide((*it).second,total); (*it).second = LogWeight::Zero(); } }else{ _conditional_max( true ); } for( unsigned int i=0; i<fsas.size(); i++ ){ for( StateIterator<VectorFst<LogArc> > siter(fsas[i]); !siter.Done(); siter.Next() ){ LogArc::StateId q = siter.Value(); for( MutableArcIterator<VectorFst<LogArc> > aiter(&fsas[i], q); !aiter.Done(); aiter.Next() ){ LogArc arc = aiter.Value(); if( penalize_em==true ){ LabelDatum* ld = &penalties[arc.ilabel]; if( ld->lhs>1 && ld->rhs>1 ){ arc.weight = 99; }else if( ld->lhsE==false && ld->rhsE==false ){ arc.weight = arc.weight.Value() * ld->tot; } /* else{ arc.weight = arc.weight.Value() * (ld->tot+10); } */ if( arc.weight == LogWeight::Zero() || arc.weight != arc.weight ) arc.weight = 99; }else{ arc.weight = alignment_model[arc.ilabel]; } aiter.SetValue(arc); } } } total = LogWeight::Zero(); return change;}
开发者ID:Joda89,项目名称:g2p,代码行数:52,
示例22: Termvoid Term (){ Factor(); EmitLn("MOVE D0,-(SP)"); while (Look[0] == '*' || Look[0] == '/'){ switch (Look[0]){ case '*': Multiply(); break; case '/': Divide(); break; default: Expected("Mulop"); } }}
开发者ID:BuckRogers1965,项目名称:Examples,代码行数:13,
示例23: pkvoid pk (int v[], int p, int inf, int sup, int k){ int pivote, pivote_sup, pivote_inf; int li=0; int ls=LVECT-1; while(p>=0){ pivote=Divide(v, li, ls); if((inf<=pivote)&&(pivote<=sup) && (k!= pivote)){ /*Caso 1: Dentro del rango*/ if(pivote==inf) li=pivote+1; else if(pivote==sup) ls=pivote-1; else{ pivote_inf=Divide(v, li, pivote-1); /*Búsqueda por abajo*/ pivote_sup=Divide(v, pivote+1, ls); /*Búsqueda por arriba*/ if(inf>pivote_inf) li=pivote_inf; if(sup<pivote_sup) ls=pivote_sup; } p--; } if(pivote>sup){/*Caso 2: Fuera del rango, por arriba*/ ls=pivote-1; } if(pivote<inf){/*Caso 3: Fuera del rango, por abajo*/ li=pivote+1; } }}
开发者ID:Einath,项目名称:AProg_Practices,代码行数:38,
示例24: VQ_target_vec_normvoid VQ_target_vec_norm(Ipp16s gain, Ipp16s nlsgain, Ipp16s* target, Ipp16s* nlstarget){ Ipp16s tmp, nlstmp, nls; Ipp32s k, aa0; Divide(16384, 14, gain, nlsgain, &tmp, &nlstmp); for(k=0; k<IDIM; k++) { aa0 = tmp * target[k]; target[k] = ShiftR_32s(aa0, 15); } *nlstarget = 2 + (nlstmp - 15); Vscale_16s(target,IDIM, IDIM, 14, target, &nls); *nlstarget = (*nlstarget) + nls; return;}
开发者ID:szhuangzan,项目名称:2011Corel,代码行数:14,
示例25: InsereInternoint InsereInterno(struct No *N, Chave chave, int p, int *itemPromovido, struct No **filhoDItemPromovido, int * valorAssociadoPromovido, int *x){ //Se for um nó nulo, insere na página pai if(N == NULL) { *itemPromovido = chave; *valorAssociadoPromovido = p; *filhoDItemPromovido = NULL; *x = 1; return PROMOVE; } //Sen C++ Dlg函数代码示例 C++ DivU64x32函数代码示例
|