Uite rezolvarea mea, daca ai nevoie de explicatii suplimentare da mesaj.
Cod:
#include <iostream>
#include <string.h>
using namespace std;
int transformare(char* a)
{
int i = 0, nr=0;
char* p, *m;
m = new char[strlen(a) + 1];
m[0] = '\0';
p = strtok(a, " ");
while (p != NULL)
{
if (strlen(p) % 2 != 0)
{
_strrev(p);
nr++;
}
strcat(m, p);
strcat(m, " ");
p = strtok(NULL, " ");
}
strcpy(a, m);
return nr;
}
int main()
{
char* a;
a = new char[100];
cout << "\nIntroduceti textul: ";
cin.getline(a, 100);
cout<<"\nNumarul de cuvinte inversate este: "<<transformare(a);
cout << "\nTextul inversat este: " << a;
return 0;
}