W poleceniu mam aby stworzyć rewers słów, np dla wejścia
Tom
Alfred
ma być output
moT
derflA.
Tylko, że jest taka notatka przy zadaniu: Do wczytania danych wejściowych wykorzystaj dynamicznie przydzielony fragment pamięci. Do iteracji po przetwarzanej tablicy znaków użyj wskaźnika.
Nie wiem co źle robię, bo program działa prawidłowo, a nie chce przejść przez system, który automatycznie sprawdza program.
void reverse(string tab) {
string reversed = tab;
std::reverse(reversed.begin(), reversed.end());
cout << reversed << endl;
}
int main()
{
int n;
cin >> n;
string *tab = new string[n];
string x;
for(int i=0; i<n; i++) {
cin >> x;
tab[i] = x;
}
for(int i=0; i<n; i++)
{
reverse(*tab);
tab++;
}
delete[] tab;
return 0;
}