Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

用队列实现

Posted by c00h00g at 2010-05-13 16:48:15 on Problem 3032
#include<iostream>
#include<queue>
using namespace std;

int a[100];
int main()
{
	int t,n,i,j;
	scanf("%d",&t);
	queue<int> q;
	while(t--)
	{
		scanf("%d",&n);
		q.push(n);
		for(i=n-1;i>=1;i--)
		{
			q.push(i);
			for(j=1;j<=i;j++)
			{
				int temp=q.front();
				q.pop();
				q.push(temp);
			}
		}
		int num=n-1;
		for(i=num;i>=0;i--)
		{
			a[i]=q.front();
			q.pop();
		}
		for(i=0;i<=num;i++)
			printf("%d ",a[i]);
		printf("\n");
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator