Please help to check
Code:
struct remittance
{
char country[100];
int total;
int highest;
int lastYearAmount;
struct remittance* left;
struct remittance* right;
};
struct topFiveCountry
{
char country[100];
int lastYearAmount;
};
struct topFiveCountry topFiveCountryResult[5];
void findTopFiveCountry(struct remittance* treeRoot, struct topFiveCountry* highestArray)
{
int i, j; /* loop counter */
if (treeRoot == NULL)
{
return;
}
if (treeRoot->lastYearAmount > highestArray + 4->lastYearAmount)
{
for (i = 0; i < 5; i++)
{
if(treeRoot->lastYearAmount > highestArray + i->lastYearAmount)
{
for(j = 3; j >= i; j--)
{
strcpy (highestArray + j->country, highestArray + j + 1 -> country);
highestArray + j->lastYearAmount = highestArray + j + 1 -> lastYearAmount;
}
strcpy (treeRoot->country, highestArray + i->country);
treeRoot->lastYearAmount = highestArray + i->lastYearAmount;
break;
}
}
}
findTopFiveCountry(treeRoot -> left, topFiveCountryResult);
findTopFiveCountry(treeRoot -> right, topFiveCountryResult);
}