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

庆祝我的第200道AC题目,HOHO

Posted by 304988557 at 2006-11-09 02:51:49 on Problem 3032
#include<iostream.h>
#include<string.h>
int main()
{
	int T,n;
	int a[15],temp[15];
	cin>>T;
	while(T--)
	{
		cin>>n;
		if(n==1) {cout<<1<<endl;}
		else
		{
			int t,i,j,k;
			t=k=0;
			memset(temp,0,sizeof(temp));
			for(i=1;i<=n;i++)
			{
				j=0;
				while(j<i)
				{
					j++;t++;					
					if(t==n) t=0;
					while(temp[t]==1)
					{
						t++;
						if(t==n) t=0;
					}					
				}
				temp[t]=1;a[t++]=i;k++;
				if(t==n) t=0;
				while(temp[t]==1&&k<n)
				{
						t++;
						if(t==n) t=0;
				}				
			}
			for(i=0;i<n;i++)
				cout<<a[i]<<" ";
			cout<<endl;
			
		}
	}
    return 0;
}

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