It takes a long time for my comp to execute this simple loop.
Now the final do while gives me the problem,even if i use if statement,it takes about 10 secs before displaying the result,which is quite ridiculous.
int counters[255] = {0};
ifstream in("ut2.txt", ios::binary);
unsigned char c;
while( in.read((char *)&c, 1) )
{
counters[c]++;
}
int h1=0,hm=0;
int da=0;
for(hm=0;hm<256;hm++)
{
da=counters[hm]+da;
}
da=da/256;
do
{
h1=0;
for(hm=0;hm<256;hm++)
{
if(counters[hm]>=da){h1++;}
}
da--;
if(h1==192){da++;break;}
}
while(h1<=192);
Can i use h1 as the condition for while and change it to 0 in the main loop ?