31.10.2016, 01:32
Alphabet Sorter
This function sorts the strings in alphabetical order
Gist Link
PHP код:
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1)
/*Alphabet sorter by Sreyas*/
alpha(str[MAX_NAMES][MAX_PLAYER_NAME]) //MAX_NAME - total number of strings in that matrix
{
new i, j,t[24];
for(i=1; i<MAX_NAMES; i++)
{
for(j=1; j<MAX_NAMES; j++)
{
if(strcmp(str[j-1], str[j])>0)
{
strcpy(t, str[j-1]);
strcpy(str[j-1], str[j]);
strcpy(str[j], t);
}
}
}
printf("Names in alphabetical order ");
for(i=0; i<MAX_NAMES; i++)
{
printf("%s",str[i]);
}
}