View Single Post
Old 04-24-2005, 12:00 PM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
The power of STL for my entertainment:
Code:
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  string TheWord("I am a string!");
  reverse(TheWord.begin(), TheWord.end());
  cout<<TheWord<<endl;
  
  return 0;
}
Code:
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  string TheWord("I am a string!");
  string Reversed(TheWord); //sizing
  reverse_copy(TheWord.begin(), TheWord.end(), Reversed.begin());
  cout<<Reversed<<endl;
  
  return 0;
}
Many variations to this code can be made. And all of them require an IQ of any one-cell organism
__________________
Valmont is offline   Reply With Quote