long replace_pattern(long inputInt)
{
int andmul = 7, ormul = 3, i = 0, lasti = 0, step = 0, product = 1;
while (i<31)
{
step = i - lasti;
lasti = i;
andmul <<= step;
ormul <<= step;
product <<= step;
if ((inputInt&andmul) == product)//循环条件、判断有001则进入或等后变为011
{
inputInt |= ormul;//将001变为011
i += 3;
}
else
i += 1;
}
return inputInt;
}
int _tmain(int argc, _TCHAR* argv[])
{
int num = 342391;
int temp = 0;
temp = replace_pattern(num);
return 0;
}