[Algorithms] KamaCoder 55. 右旋字符串(第八期模拟笔试)
Categories Algorithms String
Tags
来源:代码随想录
三次反转
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int k;
string s;
cin >> k >> s;
int index = s.size() - k;
reverse(s.begin(), s.begin() + index);
reverse(s.begin() + index, s.end());
reverse(s.begin(), s.end());
cout << s << endl;
}
Page views: Loading... · Visitors: Loading...
Except where otherwise noted, original content on this site is dedicated to the public domain under CC0 1.0.
Powered by Hexo & Theme mdsuper
沪ICP备2026040813号