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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)