Răspuns:
#include <iostream>
#include<cstring>
using namespace std;
char fraza[256], cuv1[256], cuv2[256];
int lmax = 0, lmin = 300;
int
main ()
{
cin.get (fraza, 256);
char *p = strtok (fraza, " ");
while (p)
{
if (strlen (p) > lmax)
lmax = strlen (p), strcpy (cuv1, p);
if (strlen (p) < lmin)
lmin = strlen (p), strcpy (cuv2, p);
p = strtok (NULL, " ");
}
cout << "Cuvantul de lungime minima este " << cuv2 << '\n';
cout << "Cuvantul de lungime maxima este " << cuv1;
return 0;
}
Explicație: