View Single Post
Old 10-25-2004, 05:40 AM   #1 (permalink)
Andi55
Registered User
 
Join Date: Oct 2004
Posts: 1
Andi55 is on a distinguished road
Question median of a sequel

HI

What i'm trying to do is to find the median of a string of letters.
But at first the letters must put in order alphabetically.
I have wrote a C++ Programm for this step but it doesent run correctly.
Have anyone an idea ?

Here the part of the Programm:

Code:
char* sortstring( char quelle[] )
{
	char* ziel = new char[ strlen(quelle)+1];
	char* hilfe = new char[ strlen(quelle)+1];
	int a = strlen(quelle);

	strcpy (hilfe,quelle);
	strcpy (ziel,quelle);

        for( int k=0 ; k<a ; k++)
	{
		for( int i=0 ; i<a ; i++)
		{
		if(quelle[k]<hilfe[i])
		    ziel[k]=quelle[k];
		else
		    ziel[k]=hilfe[i];
		}
	}
	ziel[k++] ='\0';
	return ziel;
}

Last edited by Andi55; 10-25-2004 at 06:15 AM.
Andi55 is offline   Reply With Quote