c++ - Frequency of alphabets repeated are not calculated properly -


I am trying to read an instance from a file to create a Hoffman tree. I am able to do this, but there is a problem. The problem is that I am using loops i and j for two and at the place where the alphabet repeats at that place, it shows "0". I believe the alphabet is "aababccc" the output is:

  a = 3, a = 0, b = 2, a = 0, b = 0, C = 3, c = 0, c = 0   

but I want to output the output like this:

  a = 3, b = 2, C = 3   

I mean that I have removed this zero from memory allocation (I am accumulating them in sim [] and freak []. Help (any language c or c ++)

  favicon flag [256]; int j = 0; four sim [256]; for integer [256]; I = 0; i & lt; gin Ii ++) flag [i] = {0}; int fcount1 = 0; sym [i] = data [i] .symbol; freak [ii] = abcount 1; fcount1 = 0;}}   

The input frequency given to it is as follows: Abacquocated which is data [index]. Symbol is:

< Strong> Everything is OK except "0". Please help me delete "0".

Just before j loop, add a condition:

  if (flag [i] == 0)   

In addition, storeym and storefreq speed The vectors and Pus_bak

  int flag [256]; // To use this flag, know that the alphabet has already been counted or not. If it is assumed that I'm setting it according to "1" according to the second, then it is "0". Please see below in my code j int = 0, i; Std :: vector & lt; Four & gt; Storesym; Std :: vector & lt; Integer & gt; Storefreq; For (i = 0; i <; count; i ++) flag [i] = {0}; Int fcount1 = 0; (I = 0; i    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -