#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Подсчитать количество слов в строке
int wcount(char *s)
{
char *p = s;
int count = 0;
while (1)
{
while (*p == ' ')
p++;
if (!*p)
break;
count++;
while (*p && (*p != ' '))
p++;
}
return count;
}
void GetWordIndex(char *s, int *count)
{
int size = 0;
int i = 0;
while (1)
{
while (s[i] == ' ')
i++;
if (s[i] == '\0')
break;
count[size] = i;
size++;
while (s[i] != '\0' && s[i] != ' ')
i++;
if (s[i] == '\0')
break;
}
}
void csort(char *src, char *dest)
{
int len = strlen(src);
int n = wcount(src);
int count[n];
int new_count[len];
int j;
for (j = 0; j < len; j++)
new_count[j] = 0;
char *p = src;
GetWordIndex(src, count);
int i;
for (i = 0; i < len, p[i] != '\0' && p[i] != ' '; i++)
for (j = 0; j < n; j++)
new_count[count[j]]++;
for (i = 0; i < n; i++)
printf("%d, ", new_count[i]);
}
int main()
{
char *scr = (char *)malloc(1024);
gets(scr);
char *dest = (char *)malloc(1024);
csort(scr, dest);
free(scr);
free(dest);
return 0;
}