Sunday, December 12, 2010

Lexicographic Sorting of Strings

//PROGRAM TO PERFORM LEXICOGRAPHIC SORTING OF GIVEN STRINGS.
#include
#include
#include
void sort(char[20][20],int);
void main()
{
char strn[20][20];
int i=0,n;
clrscr();
printf("\nEnter the number of strings to be sorted:");
scanf("%d",&n);
printf("\nEnter the %d strings:\n",n);
for(i=0;i0)
{
strcpy(temp,str[j-1]);
strcpy(str[j-1],str[j]);
strcpy(str[j],temp);
}
}
}
printf("\n-------------------------------------");
printf("\nThe sorted list is \n");
for(i=0;i {
printf("%s\n",str[i]);
}
}

No comments:

Post a Comment