Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Paraula Esquema::i_buscarAreaTematica1 (Arbre<string> &a, Revista& r, int& altura, int& nMax) {
- Paraula p;
- if (a.es_buit()) {
- p.es = false;
- altura = 0;
- }
- else if (r.esPC(a.arrel())) {
- p.es = true;
- p.nom = a.arrel();
- altura = 1;
- }
- else {
- Arbre<string> a1, a2;
- a.fills(a1, a2);
- Paraula p1, p2;
- int x,y;
- p1 = i_buscarAreaTematica1 (a1, r, x, nMax);
- p2 = i_buscarAreaTematica1 (a2, r, y, nMax);
- if (p1.es and not p2.es) {
- p.es = true;
- if (r.esPC(p1.nom)) {
- p.nom = a.arrel();
- p.altura = x+1;
- }
- else {
- p.nom = p1.nom;
- p.altura = p1.altura;
- }
- }
- else if (not p1.es and p2.es) {
- p.es = true;
- if (r.esPC(p2.nom)) {
- p.nom = a.arrel();
- p.altura = y+1;
- }
- else {
- p.nom = p2.nom;
- p.altura = p2.altura;
- }
- }
- else if (p1.es and p2.es) {
- p.es = true;
- if (r.esPC(p1.nom) and not r.esPC(p2.nom)) {
- p.nom = a.arrel();
- p.altura = x+1;
- }
- else if (not r.esPC(p1.nom) and r.esPC(p2.nom)) {
- p.nom = a.arrel();
- p.altura = y+1;
- }
- else if (r.esPC(p1.nom) and r.esPC(p2.nom)) {
- p.nom = a.arrel();
- if (x >= y)
- p.altura = x+1;
- else
- p.altura = y+1;
- }
- else {
- p.es = true;
- if ((nMax - p1.altura) == (nMax - p2.altura)) {
- if (p1.nom.compare(p2.nom) <= 0) {
- p.nom = p1.nom;
- p.altura = p1.altura;
- }
- else {
- p.nom = p2.nom;
- p.altura = p2.altura;
- }
- }
- else if ((nMax - p1.altura) > (nMax - p2.altura)) {
- p.nom = p1.nom;
- p.altura = p1.altura;
- }
- else {
- p.nom = p2.nom;
- p.altura = p2.altura;
- }
- }
- }
- else {
- p.es = false;
- }
- if (x >= y)
- altura = x+1;
- else
- altura = y+1;
- }
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement