#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int funcsortier(const void *A, const void *B)
{
char *a = (char *)A;
char *b = (char *)B;
if (*a < *b) return -1; /* kleiner */
if (*a > *b) return +1; /* grösser */
return 0; /* gleich */
}
int main()
{
char satz[80], *s, *e;
fgets(satz, sizeof(satz), stdin); /* Satz einlesen */
for (s = satz; *s; s = e)
{ while(*s == ' ' || *s == '\t') /* Whitespaces überspringen */
s++;
if (*s == 0 || *s == '\n') /* Satzende erreicht ? */
break;
for (e = s; *e && *e != ' ' && *e != '\t' && *e != '\n'; ) /* Wort */
e++;
printf("(%.*s)", e-s, s);
qsort(s, e-s, sizeof(char), funcsortier); /* Buchstaben sortieren */
}
printf("\nErgebnis: %s", satz);
getch();
return 0;
}
|