The Reverse function reverses the character order in a string.

Source: Internet
Author: User

Syntax Reverse (string) parameter string: String returned value of the string to Reverse the character order. If the function is successfully executed, the string with the reversed character order is returned. If an error occurs, the Null String ("") is returned (""). Use the Reverse () function to place the last character in a string to the first character position of another string, the last and second character to the second character position of another string, and so on. EXAMPLE: // reverse algorithm example # include <iostream> # include <algorithm> # include <vector> using namespace std; int main () {vector <int> myvector; vector <int>: iterator it; // set some values: for (int I = 1; I <10; ++ I) myvector. push_back (I); // 1 2 3 4 5 6 7 8 9 reverse (myvector. begin (), myvector. end (); // 9 8 7 6 5 4 3 2 1 // print out content: cout <"myvector contains:"; for (it = myvector . Begin (); it! = Myvector. end (); ++ it) cout <"" <* it; cout <endl; return 0;} Output: myvector contains: 9 8 7 6 5 4 3 2 1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.