现在的位置: 首页 > 综合 > 正文

算法竞赛入门经典P89 卡片游戏

2014年01月03日 ⁄ 综合 ⁄ 共 225字 ⁄ 字号 评论关闭
#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
queue<int> q;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		q.push(i+1);
	while(!q.empty()){
		printf("%d ",q.front());
		q.pop();
		q.push(q.front());
		q.pop();
	}
	return 0;

}

抱歉!评论已关闭.