Share reverse string c++

lytrucboyz

New member
**#Đảo ngược chuỗi C ++ **

**Giới thiệu**

Một chuỗi là một chuỗi các ký tự.Trong C ++, một chuỗi được biểu thị bằng lớp `String`.Lớp `String` cung cấp một số phương thức để thao tác các chuỗi, bao gồm phương thức` Reverse () `.Phương thức `Reverse ()` đảo ngược thứ tự của các ký tự trong một chuỗi.

**Ví dụ**

Mã sau đây cho thấy cách đảo ngược chuỗi bằng cách sử dụng phương thức `Reverse ()`:

`` `C ++
#include <Istream>
#include <String>

sử dụng không gian tên STD;

int main () {
// Tạo một chuỗi.
Chuỗi str = "Hello World!";

// đảo ngược chuỗi.
str.reverse ();

// In chuỗi đảo ngược.
cout << str << endl;

trả lại 0;
}
`` `

** Đầu ra **

`` `
! Dlrow olleh
`` `

**Người giới thiệu**

* [C ++ chuỗi: Phương thức Reverse ()] (https://www.tutorialspoint.com/cplusplus/string_reverse.htm)
* [Cách đảo ngược một chuỗi trong C ++] (geeksforgeek.org - geeksforgeek Resources and Information.)

** hashtags **

* #C ++
* #sợi dây
* #Đảo ngược
* #Programming
* #tutorial
=======================================
**#Reverse String C++**

**Introduction**

A string is a sequence of characters. In C++, a string is represented by the `string` class. The `string` class provides a number of methods for manipulating strings, including the `reverse()` method. The `reverse()` method reverses the order of the characters in a string.

**Example**

The following code shows how to reverse a string using the `reverse()` method:

```c++
#include <iostream>
#include <string>

using namespace std;

int main() {
// Create a string.
string str = "Hello World!";

// Reverse the string.
str.reverse();

// Print the reversed string.
cout << str << endl;

return 0;
}
```

**Output**

```
!dlrow olleH
```

**References**

* [C++ Strings: reverse() Method](https://www.tutorialspoint.com/cplusplus/string_reverse.htm)
* [How to Reverse a String in C++](https://www.geeksforgeeks.org/how-to-reverse-a-string-in-c/)

**Hashtags**

* #C++
* #String
* #Reverse
* #Programming
* #tutorial
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top