有什么函数可以翻转字符串第i到第j个字符

学术版

xiaomiao_001 @ 2024-11-29 13:49:21

rt


by Harlem @ 2024-11-29 13:50:17

reverse


by xiaomiao_001 @ 2024-11-29 13:51:36

主要是怎么指定一部分


by lzm0107 @ 2024-11-29 13:53:06

@xiaomiao_001 如果你说的字符串是 std::string 的话,使用 reverse(s.begin() + i, s.begin() + j + 1);


by lzm0107 @ 2024-11-29 13:53:34

字符数组去掉两个 .begin() 就行了


by xiaomiao_001 @ 2024-11-29 13:53:54

@lzm0107@lzm0107 谢谢!!


by lzm0107 @ 2024-11-29 13:55:27

@xiaomiao_001 哦对了我上面说的默认第一个字符是 s[1]


|