倒置函式reverse的用法

2021-08-07 15:17:56 字數 616 閱讀 3761

倒置字串函式reverse:用於倒置字串s中的各個字元的位置,如原來字串中如果初始值為123456,則通過reverse函式可將其倒置為654321,程式如下:

#include

#include

void reverse(char s)

}main()//主函式,用於測試reverse函式的功能

執行結果如下;654321

功能顛倒字串中字元次序。  語法reverse ( string )

引數string:要顛倒字元次序的字串返回值string。函式執行成功時返回顛倒字元次序後的字串,如果發生錯誤,那麼返回空字串("")。用法reverse()函式將乙個字串中最後乙個字元放置到另乙個字串的第乙個字元位置、倒數第二個字元放置在另乙個字串的第二個字元位置,以此類推。

example:

// reverse algorithm example

#include

#include

#include

using namespace std;

int main ()

output:

myvector contains: 9 8 7 6 5 4 3 2 1

倒置函式reverse的用法

倒置字串函式reverse 用於倒置字串s中的各個字元的位置,如原來字串中如果初始值為123456,則通過reverse函式可將其倒置為654321,程式如下 include include void reverse char s main 主函式,用於測試reverse函式的功能 執行結果如下 6...

reverse 反轉函式

reverse用法 1.reverse函式反轉string 2.reverse函式反轉字元陣列 例子 分析與解答 reverse用法 1.reverse函式反轉string include include include using namespace std int main 例子 題目描述 輸入...

map函式 reverse函式

居然連map都忘了 恨鐵不成鋼 總結一下 舉例 mapmp mp 3 5 mapmp mp a 24 mapmp mp taylor 1 標頭檔案 map 其實你知道這些就已經夠了但是我還是搬了點東西過來 用法舉例 map的基本操作函式 c maps是一種關聯式容器,包含 關鍵字 值 對 begin...