Advertisement
Dani_info

reverse a string

Mar 28th, 2018
122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string>
  2. #include <iostream>
  3. using namespace std ;
  4.  
  5. string reverseString (string str )
  6. {
  7.     int n=str.length();
  8.     for (int i=0; i<n/2; ++i)
  9.       {  
  10.         swap (str[i], str[n-i-1]);
  11.       }
  12.       return str;
  13. }
Advertisement
RAW Paste Data Copied
Advertisement