常规版队列(queue)题解:
2025-08-25 12:58:13
发布于:浙江
0阅读
0回复
0点赞
根据队列queue,我们可以得到:
#include <bits/stdc++.h>
using namespace std;
int main()
{
queue <int> q;
int k, n, p;
cin >> k >> n >> p;
for (int i = 1; i <= k; i++) q.push(i);
while (q.size()){
cout << q.front() << " ";
q.pop();
for (int i = 1; i <= p; i++){
q.push(q.front());
q.pop();
}
}
return 0;
}
这里空空如也
有帮助,赞一个