[try Beta version]
Not logged in

 
read substring by reverse

Feb 22, 2010 at 3:36pm
how i can read reverse what display by substring............?
Feb 22, 2010 at 7:26pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string str = "Hello World";
	
	string s = str.substr(0, 6);
	
	reverse(s.begin(), s.end());
	
	cout << "Substring reversed = " << s << endl;
	
	return 0;
}
Feb 22, 2010 at 7:36pm
Best not to give answers for free like that.
Feb 22, 2010 at 10:32pm
He didn't, this only works if you are looking to switch the first and last words in a two word string :p. There is no mobility for this code so it shows oman the fish without handing it over. He would be better off loading the input into a string array and outputting the array in reverse, is this giving away TMI?
Feb 22, 2010 at 11:07pm
Actually he is giving away the answer. Sure he is not giving the EXACT answer, but he is giving enough to make it so oman doesn't have to try at all.
Topic archived. No new replies allowed.