算法中的反转问题
Posted zousantuier
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了算法中的反转问题相关的知识,希望对你有一定的参考价值。
1 void reverse(vector<int>& word){ 2 size_t first, last; 3 first = 0; 4 last = word.size(); 5 while ((first != last) && (first != --last)) 6 std::swap(word[first++], word[last]); 7 }
反转这类题目多和其他类型的题目相结合,难度不大,其中最重要的是要掌握对字符串,数组的反转操作。
以上是关于算法中的反转问题的主要内容,如果未能解决你的问题,请参考以下文章