Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. void ListaPalabras::anadir_palabra (const Palabra & p)
  2. {
  3.   bool repetida = false;
  4.   int maxim = 0;
  5.   int i = 0;
  6.   while (not repetida and i < nparaules) {
  7.     if (p.iguales(paraules[i].par)) repetida = true;
  8.     else ++i;
  9.   }
  10.   if (not repetida) {
  11.     if (nparaules == MAXNUMPAL) throw PRO2Excepcio("paraules massa plenes");
  12.     paraules[nparaules].par = p;
  13.     paraules[nparaules].freq = 1;
  14.     ++nparaules;
  15.   }
  16.   else {
  17.     paraules[i].freq += 1;  
  18.     if (paraules[i].freq > maxim) {
  19.       maxim = paraules[i].freq;
  20.       pos_maxfrec = i;
  21.     }
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement