Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The usage of reverse () in Java
The usage of reverse () in Java
1, the reverse function reverses stringint main() {

String n;

CIN & gt; & gtn;

reverse(N.begin()、n . end());

cout & lt& ltN & lt& ltendl

}

2. The 2.reverse function inverts the character array int main() {

char a[ 10 1];

cin.getline(a,sizeof(a));

int m = strlen(a);

Reverse (a, a+m);

Put option (a);

}

Extended data

Syntax inversion (string)

Parameter String: a string return value string used to reverse the character order. This function returns an inverse string on successful execution and an empty string ("") if there is an error. Use the Reverse () function to place the last character in one string at the first character position in another string, the penultimate character at the second character position in another string, and so on.