void Hd(pilha *P, No **raiz) { No *pai_a = (No*) malloc(sizeof(No)); No *pai_resto = (No*) malloc(sizeof(No)); pilha Pilha[10000]; if(tamPilha > 1) { pai_a = pop(P); pai_resto = pop(P); if(pai_a->dir->c == '@') { DecodificaOperacao(pai_a->dir, Pilha); OP = pop(Pilha); if(OP->c == 'T') Tl(Pilha, &pai_a->dir); else if(OP->c == 'H') Hd(Pilha, &pai_a->dir); else printf("\n--ERRO!!--\n"); } pai_resto->esq = pai_a->dir->esq; DecodificaOperacao(pai_resto, P); } else if(tamPilha == 1) { pai_a = pop(P); if(pai_a->dir->c == '@') { DecodificaOperacao(pai_a->dir, Pilha); OP = pop(Pilha); if(OP->c == 'T') Tl(Pilha, &pai_a->dir); else if(OP->c == 'H') Hd(Pilha, &pai_a->dir); else printf("\n--ERRO!!--\n"); } (*raiz) = pai_a->dir->esq; DecodificaOperacao(*raiz, P); } else { Fim=1; } }
//________________| TLatex void StyleLatex(TString str="title", Double_t fmin, Double_t fmax, const Int_t fbit=0, const char *fPartype="", const Double_t xvalue =5){ TLatex Tl(0.5,0.5,"u"); Tl.SetTextFont(42); Tl.SetTextAlign(12); Tl.SetTextSize(0.035); Tl.SetTextColor(46); Tl.DrawLatex(xvalue,0.64, Form("Configurations")); Tl.DrawLatex(xvalue,0.62, "___________________"); Tl.DrawLatex(xvalue,0.58, Form("1. Filterbit: %d", fbit)); Tl.DrawLatex(xvalue,0.54, Form("2. Particle Type: %s", fPartype)); if(str.Contains("PT") || str.Contains("PT") || str.Contains("Pt")){ Tl.DrawLatex(xvalue,0.50, Form("3. %.1f #leq #eta #leq %.1f ", -0.9, 0.9)); Tl.DrawLatex(xvalue,0.46, Form("4. %.1f #leq Zvtx #leq %.1f (cm)", -10., 10.)); Tl.DrawLatex(xvalue,0.42, Form("5. %.1f #leq p_{T} #leq %.1f (GeV/c)", fmin, fmax)); } else if(str.Contains("eta") || str.Contains("ETA") || str.Contains("Eta")){ Tl.DrawLatex(xvalue,0.50, Form("3. %.1f #leq p_{T} #leq %.1f (GeV/c)", 0.5, 24.)); Tl.DrawLatex(xvalue,0.46, Form("4. %.1f #leq Zvtx #leq %.1f (cm)", -10., 10.)); Tl.DrawLatex(xvalue,0.42, Form("5. %.1f #leq Eta #leq %.1f ", fmin, fmax)); } else if(str.Contains("zvtx") || str.Contains("ZVTX") || str.Contains("Zvtx")){ Tl.DrawLatex(xvalue,0.50, Form("3. %.1f #leq #eta #leq %.1f ", -0.9, 0.9)); Tl.DrawLatex(xvalue,0.46, Form("4. %.1f #leq p_{T} #leq %.1f (GeV/c)", 0., 24.)); Tl.DrawLatex(xvalue,0.42, Form("5. %.1f #leq AvgZv #leq %.1f (cm)", fmin, fmax)); } else { Tl.DrawLatex(xvalue,0.50, Form("3. %.1f #leq Zvtx #leq %.1f (cm)", -10., 10.)); Tl.DrawLatex(xvalue,0.46, Form("4. %.1f #leq #eta #leq %.1f ", -0.9, 0.9)); Tl.DrawLatex(xvalue,0.42, Form("5. %.1f #leq p_{T} #leq %.1f (GeV/c)", 0.0, 24.0)); } }
int main() { int i; char strEntrada[200000]; No *Raiz; pilha Pilha[10000]; OP = (No*) malloc(sizeof(No)); FILE *arq = fopen("string.in", "r"); fscanf(arq,"%s",strEntrada); criaNo('@', &Raiz); Raiz = criaGrafo(strEntrada, Raiz); DecodificaOperacao(Raiz, Pilha); //for(i = 0; i<1; i++) while(Fim == 0 && Raiz->c != ':' && Raiz->c != '$') { OP = pop(Pilha); switch (OP->c) { case 'S': if(Verifica(3,Pilha, &Raiz)) { S(Pilha, &Raiz); #ifdef CONT_FLAG cont_S++; #endif } break; case 'K': K(Pilha, &Raiz); #ifdef CONT_FLAG cont_K++; #endif break; case 'B': if(Verifica(3,Pilha, &Raiz)) { B(Pilha, &Raiz); #ifdef CONT_FLAG cont_B++; #endif } break; case 'b': if(Verifica(3,Pilha, &Raiz)) { BL(Pilha, &Raiz); #ifdef CONT_FLAG cont_BL++; #endif } break; case 'P': if(Verifica(3,Pilha, &Raiz)) { CL(Pilha, &Raiz); #ifdef CONT_FLAG cont_CL++; #endif } break; case 'I': I(Pilha, &Raiz); #ifdef CONT_FLAG cont_I++; #endif break; case 'W': if(Verifica(3,Pilha, &Raiz)) { SL(Pilha, &Raiz); #ifdef CONT_FLAG cont_SL++; #endif } break; case 'C': if(Verifica(3,Pilha, &Raiz)) { C(Pilha, &Raiz); #ifdef CONT_FLAG cont_C++; #endif } break; case 'H': //Hd Hd(Pilha, &Raiz); break; case 'T': //Tl Tl(Pilha, &Raiz); break; case '*': MULT(Pilha, &Raiz); break; case '/': DIV(Pilha, &Raiz); break; case '-': SUB(Pilha, &Raiz); break; case '+': ADD(Pilha, &Raiz); break; case '^': POT(Pilha, &Raiz); break; default: Fim = 1; break; } } printf("Saida: "); printaGrafo(Raiz); printf("\n"); printf("\nChamadas ao GC:%d\n", garbage); #ifdef CONT_FLAG printf("S: %d\n",cont_S); printf("K: %d\n",cont_K); printf("I: %d\n",cont_I); printf("C: %d\n",cont_C); printf("B: %d\n",cont_B); printf("S': %d\n",cont_SL); printf("C': %d\n",cont_CL); printf("B': %d\n",cont_BL); #endif return 0; }