void deal(char *input, char *inputSub)
{
int strLen1 = strlen(input);
int strLen2 = strlen(inputSub);
int irl = 0;
int iponit1 = 0;
int iponit2 = 0;
int iMallocLen = 0;
while(irl < strLen1)
{
if(input[irl] == '.')
{
iponit1 = irl;
break;
}
irl++;
}
irl = 0;
while(irl < strLen2)
{
if(inputSub[irl] == '.')
{
iponit2 = irl;
break;
}
irl++;
}
if(iponit2 > iponit1)
{
iMallocLen = iponit2 - iponit1;
}
else
{
iMallocLen = iponit1 - iponit2;
}
if(strLen1 > strLen2)
{
iMallocLen +=strLen1;
}
else
{
iMallocLen +=strLen2;
}
char *inputMalloc = (char *)malloc(iMallocLen);
char *inputsubMalloc = (char *)malloc(iMallocLen);
memset(inputMalloc, NULL, iMallocLen);
memset(inputsubMalloc, NULL, iMallocLen);
if((iponit1 == 0)&&(iponit2 == 0))
{
strcpy(inputMalloc, input);
strcpy(inputsubMalloc, inputSub);
}
else if((iponit1 == 0)&&(iponit2 != 0))
{
strcpy(inputMalloc, input);
irl = 0;
while(irl < strLen2 - iponit2 - 1)
{
inputMalloc[strLen1 + irl] = '0';
irl++;
}
strncpy(inputsubMalloc, inputSub, iponit2);
strcat(inputsubMalloc, inputSub+iponit2+1);
}
else if((iponit1 != 0)&&(iponit2 == 0))
{
strcpy(inputsubMalloc, inputSub);
irl = 0;
while(irl < strLen1 - iponit1 - 1)
{
inputsubMalloc[strLen2 + irl] = '0';
irl++;
}
strncpy(inputMalloc, input, iponit1);
strcat(inputMalloc, input+iponit1+1);
}
else
{
strncpy(inputMalloc, input, iponit1);
strcat(inputMalloc, input+iponit1+1);
strncpy(inputsubMalloc, inputSub, iponit2);
strcat(inputsubMalloc, inputSub+iponit2+1);
if((strLen1 - iponit1) > (strLen2 - iponit2))
{
irl = 0;
while(irl < (strLen1 - iponit1) - (strLen2 - iponit2))
{
inputsubMalloc[strLen2 + irl -1] = '0';
irl++;
}
}
else
{
irl = 0;
while(irl < (strLen2 - iponit2)-(strLen1 - iponit1))
{
inputMalloc[strLen1 + irl - 1] = '0';
irl++;
}
}
}
}
阅读(2585) | 评论(0) | 转发(0) |