佣金计算详解02:获取目标值(比较项:一个或多个)二分查找

int getDepGroupNo(char* pAgentNo , char* pGroupNo , char *pAgentLevel , char* pContractNo, char* pDeptNo )
{
int iHigh;
int iLow;
int iMid; /* 二分法查找用 */
int iReturn;


iLow = 0;
iHigh = gl_agentContract_num -1;
iReturn = -1;

while(iLow<=iHigh)
{
iMid = (iLow + iHigh)/2;
iReturn = strcmp(pAgentNo,gp_agentContract[iMid].agentNo);

if(iReturn==0)
{
strcpy(pGroupNo, gp_agentContract[iMid].groupNo);
return 0;
}
else if(iReturn > 0)
iLow = iMid + 1;
else
iHigh = iMid - 1;
}
if(iReturn!=0)
{
return -1;
}
}

 

 

int getInNetModeGroup(char *aModeGroup,char *aInnetMode)
{
int iHigh;
int iLow;
int iMid; /* 二分法查找用 */
int iReturn;
int iReturn2;
char feeId[6];

iLow = 0;
iHigh = gl_modegroup_num -1;
iReturn = -1;

while(iLow<=iHigh)
{
iMid = (iLow + iHigh)/2;

iReturn = strcmp(aModeGroup,gp_modeGroup[iMid].modeGroup);
iReturn2 = strcmp(aInnetMode,gp_modeGroup[iMid].innetMode);
if(iReturn==0)
{
if(iReturn2==0)
{
return 0;
}
else if(iReturn2 > 0)
iLow = iMid + 1;
else
iHigh = iMid - 1;
}
else if(iReturn > 0)
iLow = iMid + 1;
else
iHigh = iMid - 1;
}
if(iReturn!=0||iReturn2!=0)
return -1;

}

你可能感兴趣的:(佣金计算详解02:获取目标值(比较项:一个或多个)二分查找)