Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Done", "done", or "d" for the line of text.
Ex: If the input is:
Hello there
Hey
donethen the output is:
ereht olleH
yeH#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
string s;
getline(cin,s);
while((s!="Done")&&(s!="done")&&(s!="d"))
{
reverse(s.begin(),s.end());
cout<<s<<endl;
getline(cin,s);
}
return 0;
}
Comments