C++ 环状移动
#include <iostream>
#include <list>
int main() {
auto list = std::list<int>{1, 3, 5, 7, 9};
for (auto i = 0; i < 16; i++) {
std::cout << list.front() << std::endl;
list.splice(list.end(), list, list.begin());
}
std::cout << "==============================" << std::endl;
return 0;
}
输出
1
3
5
7
9
1
3
5
7
9
1
3
5
7
9
1
==============================
Process finished with exit code 0