#include <iostream>
#include <string>
using namespace std;
void preserveString(string word, int sz)
{
while (sz > 0)
{
cout << word.substr(0, sz-1) << endl;
return preserveString(word, sz - 1);
}
}
int main()
{
string word;
cout << "Please, enter a string: ";
cin >> word;
preserveString(word, word.size());
}
Comments
Leave a comment