Skip to content

Instantly share code, notes, and snippets.

@mesbahamin
Created March 23, 2017 05:15
Show Gist options
  • Save mesbahamin/b016a496d669553bef4c12b468c6903e to your computer and use it in GitHub Desktop.
Save mesbahamin/b016a496d669553bef4c12b468c6903e to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using namespace std;
void recursive(string s, int count, int limit)
{
if (count < limit)
{
for (int i = 0; i < count; i++)
{
cout << ' ';
}
cout << s[count];
for (int i = count + 1; i < limit; i++)
{
cout << '|';
}
cout << endl;
recursive(s, ++count, limit);
}
}
int main()
{
bool quit = false;
string input = "Ah yes, recursion...";
cout << input << endl;
do {
recursive(input, 0, input.length());
cout << "Enter another message (or type 'Quit' to quit:" << endl;
getline(cin, input);
if (input == "Quit")
{
quit = true;
}
} while(!quit);
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment