Advertisement
rizky_herucakra

Reversing a string

Oct 1st, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  TestStringReverse
  4. //
  5. //  Created by Rizky Herucakra on 10/1/13.
  6. //  Copyright (c) 2013 Rizky Herucakra. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <string>
  11. #include <algorithm>
  12.  
  13. using namespace std;
  14.  
  15. int main(int argc, const char * argv[])
  16. {
  17.  
  18.     cout << "Masukkan satu kata : " << endl;
  19.     string input = "";
  20.     cin >> input;
  21.     cout << "reversenya : ";
  22.     copy(input.rbegin(), input.rend(), ostream_iterator<char>(cout));
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement