Răspuns:
#include <bits/stdc++.h>
using namespace std;
char s[260],*p;
int k;
struct cuvant{
char y[260];
}x[260];
int main()
{
cin.get(s,260);
p = strtok(s," ");
while( p ){
strcpy(x[++k].y,p);
p = strtok(NULL," ");
}
for(int i = 1; i < k; i++)
for(int j = i + 1; j <= k; j++)
if( strlen(x[i].y) < strlen(x[j].y) || (strlen(x[i].y) == strlen(x[j].y) && strcmp(x[i].y,x[j].y) > 0) )
swap(x[i],x[j]);
for(int i = 1; i <= k; i++)
cout << x[i].y << '\n';
return 0;
}
Explicație: