top1编程
← 返回题目
题解

【基础】取扑克牌

1 条题解

  • 0
    @ 2026-7-28 23:03:28
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int n;
    	cin>>n;	
    	queue<int>q;
    	for(int i=0;i<n;i++){
    		int x;
    		cin>>x;
    		q.push(x);
    	}
    	while(!q.empty()){
    		cout<<q.front()<<" ";
    		q.pop();
    		if(q.empty()) break; //队空就不要再取元素
    		int r=q.front();
    		q.pop();
    		q.push(r);
    	}
    	return 0;
    }
    
    • 1