please I want to reverse word using stl like that
input
this is a test
output
test a is this
please I want to reverse word using stl like that
input
this is a test
output
test a is this
Show the code that you have so far.
Kurt
but it didnt work :/Code:#include<iostream> #include<string> #include<vector> using namespace std; int main() { string str; int x; vector<string>v; cin>>x; cin.ignore(); for(int i=1;i<=x;i++) { getline(cin,str); str.rbegin()==str.rend(); cout<<"Case #"<<i<<": "<<str<<endl; } return 0; }
Line 15 does not do anything.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
how could i reverse a vector with string????
Given that your code shows absolutely no attempt to reverse anything, how about you think a bit more?
This is not a free code factory and it is not a free homework factory, and you will not get help here unless you demonstrate effort to solve the problem (i.e. post something that people can look at and realise you have genuinely tried).
At this stage, your code reads strings, but neither inserts any of those strings into the vector, and also demonstrates no attempt to reverse anything. So you're not meeting your side of the deal.
And hacking at random and bluffing will not work. The solution is VERY simple, so we know what people will probably do if they genuinely try.
Last edited by grumpy; 08-04-2012 at 05:03 PM.
I am really tried and I am already studied stl so I tried to solve this problem so I want to know how to reverse a string with vector and I search on the internet to find but it didn't work
I'm sorry if I bothered you
Last edited by sarasaad; 08-04-2012 at 05:14 PM.
Your code does not actually use the vector that you declared. If you put each of the words in the vector, all you really have to do is figure out how to arrange the output in reverse.