#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
void handover (char ch, char *str)
{
for(size_t i = 0; i < strlen(str); i++)
{
if( ch == toupper(str[i]) )
{
if( isupper(str[i]) )
str[i]+=32;
else
str[i]-=32;
}
}
}
char *work_on_strings(const char *a, const char *b) {
size_t lena = strlen(a), lenb = strlen(b), i;
char *stra = (char*)malloc(lena * sizeof(char) +1);
char *strb = (char*)malloc(lenb * sizeof(char) +1);
char *strc = (char*)malloc( (lena + lenb) * sizeof(char) +2);
strncpy( stra, a, lena+1 ); strncpy( strb, b, lenb+1 );
int character[26] = {0};
for( i = 0; i < lena; i++ )
{
character[ toupper(stra[i]) - 'A' ] ++;
}
for( i = 0; i < 26; i++ )
{
if( character[i] % 2 == 1 )
handover( i + 65, strb );
}
memset( character, 0 , sizeof(int) * 26 );
for( i = 0; i < lenb; i++ )
{
character[ toupper(strb[i]) - 'A' ] ++;
}
for( i = 0; i < 26; i++ )
{
if( character[i] % 2 == 1 )
handover( i + 65, stra );
}
strncpy( strc, stra ,lena+1);
strncat( strc, strb ,lenb+1);
free(stra); free(strb);
return strc;
}
06-08
10-21
02-24