Rename reversestrin.cpp to Apostropheqq.cpp

This commit is contained in:
Luke Oliff
2018-10-08 17:45:22 +01:00
committed by GitHub
parent c7bf836a88
commit 6c1f8ffa4a

21
code/Apostropheqq.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include <iostream>
using namespace std;
void reverse(const string& a);
int main()
{
string str;
cout << " Please enter a string " << endl;
getline(cin, str);
reverse(str);
return 0;
}
void reverse(const string& str)
{
size_t numOfChars = str.size();
if(numOfChars == 1)
cout << str << endl;
else
{
cout << str[numOfChars - 1];
reverse(str.substr(0, numOfChars - 1));
}