POJ1013 Counterfeit Dollar 解题报告(二)
r = true;
coin[index].count++;
if(coin[index].type != DOLLAR)
{
int iType = ((j>0) iTypeRight : iTypeLeft);
if(coin[index].type == UNDEFINED)
coin[index].type = iType;
else if(coin[index].type != iType)
coin[index].type = DOLLAR;
}
}
}
} // end else
}
// search
int search(COIN* coin)
{
int iMaxCount = 0;
int iCounterfeit = -1;
for(int j = 0; j < N; ++j)
{
if(coin[j].appear && coin[j].type != DOLLAR && coin[j].count > iMaxCount)
{
iMaxCount = coin[j].count;
iCounterfeit = j;
}
}
return iCounterfeit;
}