#include <iostream> #include <vector> #include <deque> using namespace std; int main() { int T; cin >> T; for (int i = 0; i < T; i++) { int n; cin >> n; int *array = new int[n]; deque<int*> deq; for (int i = 0; i < n; i++) deq.push_back((array + i)); int cnt = 1; while (!deq.empty()) { int *x = deq.front(); deq.pop_front(); deq.push_back(x); x = deq.front(); *x = cnt++; deq.pop_front(); } int index = 0; for (; index < n - 1; index++) cout << array[index] << " "; cout << array[index] << endl; } return 0; }
点赞 评论

相关推荐

不愿透露姓名的神秘牛友
09-11 13:00
投递长江存储等公司10个岗位
点赞 评论 收藏
分享
09-01 11:31
门头沟学院 Java
buul:七牛云的吧,感觉想法是好的,但是大家没那么多时间弄他这个啊。。。不知道的还以为他是顶尖大厂呢还搞比赛抢hc,只能说应试者的痛苦考察方是无法理解的,他们只会想一出是一出
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务